Module:Based on/sandbox: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
function p._main(args) |
function p._main(args) |
||
return args[3] and string.format( |
|||
'%s <br /><span style="vertical-align:top">by </span><div class="plainlist" style="display:inline-block">\n* %s</div>', |
|||
⚫ | |||
⚫ | |||
local h = mw.html.create('ul') |
|||
table.concat(args, '\n* ', 2) |
|||
for i, v in ipairs(args) do |
|||
) |
|||
if i ~= 1 then |
|||
or args[2] and string.format( |
|||
h:tag('li'):wikitext(v):done() |
|||
⚫ | |||
end |
|||
args[1], |
|||
end |
|||
args[2] |
|||
h = mw.html.create() |
|||
) |
|||
:wikitext(s .. ' ') |
|||
⚫ | |||
:tag('br') |
|||
:done() |
|||
:tag('span') |
|||
:css('vertical-align', 'top') |
|||
:wikitext('by ') |
|||
:done() |
|||
:tag('div') |
|||
:addClass('plainlist') |
|||
:css('display', 'inline-block') |
|||
:node(h) |
|||
:allDone() |
|||
s = h |
|||
elseif args[2] then |
|||
⚫ | |||
⚫ | |||
end |
|||
return s |
|||
end |
end |
||
function p.main(frame) |
function p.main(frame) |
||
return p._main(frame:getParent().args) |
return p._main(mw.clone(frame:getParent().args)) |
||
end |
end |
||
Revision as of 20:45, 21 January 2020
![]() | This is the module sandbox page for Module:Based on (diff). |
![]() | This Lua module is used on approximately 29,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
This module implements {{Based on}}
Usage
To directly call this module (all arguments except work name optional):
{{#invoke:Based on|lua_main|Work name|Writer 1|Writer 2|...}}
To call it from a template, passing on the arguments from it:
{{#invoke:Based on|main}}
local p = {}
function p._main(args)
return args[3] and string.format(
'%s <br /><span style="vertical-align:top">by </span><div class="plainlist" style="display:inline-block">\n* %s</div>',
args[1],
table.concat(args, '\n* ', 2)
)
or args[2] and string.format(
'%s <span style="display:inline-block">by %s</span>',
args[1],
args[2]
)
or args[1]
end
function p.main(frame)
return p._main(mw.clone(frame:getParent().args))
end
return p