Module:Based on/sandbox: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
local s = args[1] |
local s = args[1] |
||
if args[2] then |
if args[2] then |
||
s = mw.html.create():wikitext(s .. ' ') |
s = mw.html.create() |
||
:wikitext(s .. ' ') |
|||
⚫ | |||
⚫ | |||
s:tag('br'):done() |
|||
end |
|||
s:tag(args[3] and 'div' or 'span') |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
:done() |
:done() |
||
:tag(args[3] and 'div' or 'span') |
:tag(args[3] and 'div' or 'span') |
||
:addClass(' |
:addClass('nowrap') |
||
: |
:tag('span') |
||
:css(' |
:css('vertical-align', 'top') |
||
⚫ | |||
⚫ | |||
⚫ | |||
:css('padding-right', '1.25em') |
|||
: |
:tag(args[3] and 'div' or 'span') |
||
⚫ | |||
⚫ | |||
:addClass(args[3] and 'plainlist') |
|||
:css('display', 'inline-block') |
|||
⚫ | |||
⚫ | |||
:wikitext(args[3] and |
|||
⚫ | |||
⚫ | |||
⚫ | |||
:done() |
:done() |
||
⚫ | |||
end |
end |
||
return s |
return s |
Latest revision as of 08:29, 23 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
[edit]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)
local s = args[1]
if args[2] then
s = mw.html.create()
:wikitext(s .. ' ')
:tag('br')
:done()
:tag(args[3] and 'div' or 'span')
:addClass('nowrap')
:tag('span')
:css('vertical-align', 'top')
:wikitext('by ')
:done()
:tag(args[3] and 'div' or 'span')
:addClass('wrap')
:addClass(args[3] and 'plainlist')
:css('display', 'inline-block')
-- Prevents the text from spilling out
:css('padding-right', '1.25em')
:wikitext(args[3] and
'\n* ' .. table.concat(args, '\n* ', 2) .. '\n'
or args[2])
:done()
:done()
end
return s
end
function p.main(frame)
-- mw.clone makes table.concat possible
return p._main(mw.clone(frame:getParent().args))
end
return p