Module:Infocard: Difference between revisions
Jump to navigation
Jump to search
(Created page with "local p = {} local getArgs function p.main(frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end local args = getArgs(frame, { wrappers = 'Templ...") |
No edit summary |
||
Line 14: | Line 14: | ||
function p._main(args) | function p._main(args) | ||
local container = mw.html.create('div') | local container = mw.html.create('div') | ||
:attr('class', 'infocard ' .. args.class) | :attr( 'class', 'infocard ' .. (args.class or '') ) | ||
local topbar = mw.html.create('div') | local topbar = mw.html.create('div') | ||
:attr('class', 'topbar') | :attr('class', 'topbar') | ||
Line 33: | Line 33: | ||
:done() | :done() | ||
end | end | ||
topbar:node( | topbar:node(middle) | ||
topbar:tag('div') | topbar:tag('div') | ||
:attr('class', 'right') | :attr('class', 'right') | ||
:wikitext(args.headerright) | :wikitext(args.headerright) | ||
:done() | :done() | ||
container:node( | container:node(topbar) | ||
local inner = mw.html.create('div') | local inner = mw.html.create('div') | ||
:attr('class', 'inner') | :attr('class', 'inner') | ||
Line 49: | Line 49: | ||
i = i + 1 | i = i + 1 | ||
end | end | ||
container:node( | container:node(inner) | ||
return tostring(container) | return tostring(container) |
Revision as of 00:23, 23 February 2016
The above documentation is transcluded from Module:Infocard/doc.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
local p = {}
local getArgs
function p.main(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
local args = getArgs(frame, {
wrappers = 'Template:Infocard'
})
return p._main(args)
end
function p._main(args)
local container = mw.html.create('div')
:attr( 'class', 'infocard ' .. (args.class or '') )
local topbar = mw.html.create('div')
:attr('class', 'topbar')
topbar:tag('div')
:attr('class', 'left')
:wikitext(args.headerleft)
:done()
local middle = mw.html.create('div')
:attr('class', 'middle')
middle:tag('div')
:attr('class', 'header')
:wikitext(args.header)
:done()
if args.subheader then
middle:tag('div')
:attr('class', 'subheader')
:wikitext(args.subheader)
:done()
end
topbar:node(middle)
topbar:tag('div')
:attr('class', 'right')
:wikitext(args.headerright)
:done()
container:node(topbar)
local inner = mw.html.create('div')
:attr('class', 'inner')
local i = 1
while args[i] do
inner:tag('div')
:attr('class', 'block')
:wikitext(args[i])
:done()
i = i + 1
end
container:node(inner)
return tostring(container)
end
return p