Difference between revisions of "Module:SB Infobox Begin"
Jump to navigation
Jump to search
Line 23: | Line 23: | ||
function p._section(args) | function p._section(args) | ||
local output = "" | local output = "" | ||
for | for i = #args, 1, -1 do | ||
local newRow = mw.html.create('div') | local newRow = mw.html.create('div') | ||
:addClass('SB-Infobox-Data-Cell') | :addClass('SB-Infobox-Data-Cell') | ||
Line 33: | Line 33: | ||
:wikitext(tostring(k)) | :wikitext(tostring(k)) | ||
output = output .. tostring(newRow) | output = output .. tostring(newRow) | ||
end | |||
return tostring(output) | return tostring(output) | ||
end | end |
Revision as of 21:03, 17 May 2021
Documentation for this module may be created at Module:SB Infobox Begin/doc
local getArgs = require('Module:Arguments').getArgs
local p = {}
function switch_key_val(tbl)
local rtbl = {}
for k,v in pairs(tbl) do
rtbl[v] = k
end
return rtbl
end
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p.section(frame)
local args = getArgs(frame)
local remap = switch_key_val(args)
return p._section(remap)
end
function p._section(args)
local output = ""
for i = #args, 1, -1 do
local newRow = mw.html.create('div')
:addClass('SB-Infobox-Data-Cell')
newRow:tag('div')
:addClass('SB-Infobox-Cell-Header')
:wikitext(tostring(v))
newRow:tag('div')
:addClass('SB-Infobox-Cell-Body')
:wikitext(tostring(k))
output = output .. tostring(newRow)
end
return tostring(output)
end
function p._main(args)
local output = ""
for k,v in pairs(args) do
output = output .. tostring(v)
end
return tostring(output)
end
return p