Module:Sprite: Difference between revisions

Created page with "local p = {} function p.base( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge( true ) else f = mw.getCurrentFrame()..."
Change sections to use unique IDs.
Line 183: Line 183:
local sections = {}
local sections = {}
for _, sectionName in ipairs( data.sections or { 'Uncategorized' } ) do
for _, sectionData in ipairs( data.sections or { 'Uncategorized' } ) do
local sectionTag = body:tag( 'div' ):addClass( 'spritedoc-section' )
local sectionTag = body:tag( 'div' ):addClass( 'spritedoc-section' ):attr( 'data-section-id', sectionData.id )
-- https://phabricator.wikimedia.org/T73594
-- https://phabricator.wikimedia.org/T73594
sectionTag:wikitext( '<h3>', sectionName, '</h3>' )
sectionTag:wikitext( '<h3>', sectionData[1], '</h3>' )
sections[sectionName] = { boxes = sectionTag:tag( 'ul' ):addClass( 'spritedoc-boxes' ) }
sections[sectionData.id] = { boxes = sectionTag:tag( 'ul' ):addClass( 'spritedoc-boxes' ) }
end
end
Line 201: Line 201:
local val = data.ids[name]
local val = data.ids[name]
local pos = val.pos
local pos = val.pos
local sectionName = data.sections[val.section]
local section = sections[val.section]
local section = sections[sectionName]
local names = section[pos]
local names = section[pos]
if not names then
if not names then