Module:Shortcut

Revision as of 20:18, 22 March 2024 by Habblet (talk | contribs) (Created page with "local p = {} function p.main(frame) local args = frame:getParent().args return p._main(args) end function p._main(args) local div = mw.html.create('div') :addClass('shortcut noprint plainlist') :wikitext('Shortcut') local numargs = 0 for i, v in ipairs(args) do numargs = numargs + 1 end if numargs > 1 then div:node('s') end div:node(':') local list = div:tag('ul'...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Module documentation
This documentation is transcluded from Module:Shortcut/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Shortcut/doc. [edit]
Module:Shortcut's function main is invoked by Template:Shortcut.

local p = {}

function p.main(frame)
    local args = frame:getParent().args
    return p._main(args)
end

function p._main(args)
    local div = mw.html.create('div')
        :addClass('shortcut noprint plainlist')
        :wikitext('[[Brighter Shores:Shortcut|Shortcut]]')

    local numargs = 0
    for i, v in ipairs(args) do
        numargs = numargs + 1
    end    

    if numargs > 1 then
        div:node('s')
    end
    div:node(':')

    local list = div:tag('ul')
    for i, v in ipairs(args) do
        list:tag('li'):wikitext('[[' .. v .. ']]')
    end

    return tostring(div)
end

--[[ DEBUG COPYPASTA
= p._main({'Link 1', 'Link 2', 'Link 3', 'Link 4'})
--]]

return p