Module:Shortcut

From Old School Near-Reality Wiki
Revision as of 20:14, 3 October 2022 by Jacmob (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)
Jump to navigation Jump to search
Module documentation
This documentation is transcluded from Template:No documentation/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('[[Near-Reality: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