Module:PortableNavbox: Difference between revisions
Jump to navigation
Jump to search
Mediawiki>Siroopwafel mNo edit summary |
m (1 revision imported) |
Revision as of 02:24, 30 April 2021
Documentation for this module may be created at Module:PortableNavbox/doc
-- <nowiki> local p = {} local yesno = require('Dev:Yesno') local title = mw.title.getCurrentTitle() function p.main(frame) local args = frame:getParent().args local contents = { '<infobox theme="', args.theme or 'navbox', '"><group' } if yesno(args.collapse or true, true) then table.insert(contents, ' collapse="closed"') end table.insert(contents, '>') if args[1] then table.insert(contents, '<header>') table.insert(contents, mw.text.trim(args[1])) table.insert(contents, '</header>') end for k, v in ipairs(args) do local i = tonumber(k) if i and v and i > 1 then i = i - 2 if i % 2 == 0 then table.insert(contents, '<data><label>') table.insert(contents, mw.text.trim(v)) table.insert(contents, '</label>') else local r = mw.ustring.gsub(mw.text.trim(v), table.concat({' ', args.separator or '!', ' '}), ' • ') table.insert(contents, '<default>') table.insert(contents, mw.text.trim(r)) table.insert(contents, '</default></data>') end end end table.insert(contents, '</group></infobox>') contents = table.concat(contents) if title.namespace ~= 829 or title.subpageText ~= 'testcases' then contents = frame:preprocess(contents) end return contents end return p