Difference between revisions of "Module:Based on"
Jump to navigation
Jump to search
blackwiki>Nyuszika7H (Don't italicize as not always appropriate, template didn't auto-italicize either) |
m (5 revisions imported) |
||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 20: | Line 20: | ||
h:wikitext(s) | h:wikitext(s) | ||
h:tag('br') -- h:newline() is not working for some reason | h:tag('br') -- h:newline() is not working for some reason | ||
| − | h:wikitext('by') | + | h:wikitext('by ') |
h:wikitext(frame:expandTemplate{ title = 'Unbulleted list', args = args }) | h:wikitext(frame:expandTemplate{ title = 'Unbulleted list', args = args }) | ||
return h | return h | ||
elseif frame.args[2] then | elseif frame.args[2] then | ||
| − | s = s .. ' by ' .. frame.args[2] | + | s = s .. '<br />by ' .. frame.args[2] |
return s | return s | ||
end | end | ||
Latest revision as of 13:22, 26 September 2020
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.lua_main(frame)
local s = frame.args[1]
if frame.args[3] then
local args = {}
for i, v in ipairs(frame.args) do
if i >= 2 then
args[#args+1] = v
end
end
args['style'] = 'display: inline'
args['list_style'] = 'display: inline'
args['item1_style'] = 'display: inline'
h = mw.html.create('div')
h:wikitext(s)
h:tag('br') -- h:newline() is not working for some reason
h:wikitext('by ')
h:wikitext(frame:expandTemplate{ title = 'Unbulleted list', args = args })
return h
elseif frame.args[2] then
s = s .. '<br />by ' .. frame.args[2]
return s
end
return s
end
function p.main(frame)
return p.lua_main(frame:getParent())
end
return p