Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:InfoboxTool: Difference between revisions

From North Forge
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
-- test with =p.infobox{args={["title"]="my title",["avalue"]="acontent"}}


local p = {}
function p.infobox(frame)
-- this is a comment
    -- Get parameters passed from the template call
-- more comments
    local params = frame.args
--[[a multi
 
line comment]]
    -- Create the HTML for the infobox
    local infobox = mw.html.create('table')
        :addClass('infobox')
        :css('width', '22em')


function p.toolInfobox( frame )
    -- Add a title row if a title is provided
--if frame.args[1] == nil
    if params.title then
        infobox:tag('tr')
return p.testParameters(frame.args[1])
            :tag('th')
                :attr('colspan', '2')
end
                :css('text-align', 'center')
                :wikitext(params.title)
    end


function p.testParameters( myParameter )
    -- 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 "<table class=\"infobox\"> <tr class=\"infobox-header\"> <th colspan=\"2\">[[Tools]]</th> </tr> </table>"
    return tostring(infobox)
  return "<table><tr>a</tr>/table>"
end
end  


return p
return p

Latest revision as of 21:51, 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={["title"]="my title",["avalue"]="acontent"}}

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