More actions
Ttenbergen (talk | contribs) No edit summary |
Ttenbergen (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
-- test with =p.infobox{args={"a",["title"]="my title","b"}} | |||
function p.infobox(frame) | function p.infobox(frame) | ||
-- Get parameters passed from the template call | -- Get parameters passed from the template call | ||
local params = frame | local params = frame.args | ||
-- Create the HTML for the infobox | -- Create the HTML for the infobox |
Revision as of 21:47, 2024 May 29
This was set up to generate infoboxes via Scribunto/Lua, but hasn't been developed further.
local p = {}
-- test with =p.infobox{args={"a",["title"]="my title","b"}}
function p.infobox(frame)
-- Get parameters passed from the template call
local params = frame.args
-- Create the HTML for the infobox
local infobox = mw.html.create('table')
:addClass('infobox')
:css('width', '22em')
-- Add a title row if a title is provided
if params.title then
infobox:tag('tr')
:tag('th')
:attr('colspan', '2')
:css('text-align', 'center')
:wikitext(params.title)
end
-- Add rows for each parameter
for key, value in pairs(params) do
if key ~= 'title' then
infobox:tag('tr')
:tag('th')
:wikitext(key)
:done()
:tag('td')
:wikitext(value)
end
end
return tostring(infobox)
end
return p