Jump to content

Module:Based on/sandbox: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 2: Line 2:


function p._main(args)
function p._main(args)
return args[2] and string.format(
local s = args[1]
if args[2] then
'%s <br /><div class="nowrap"><span style="vertical-align:top">by </span><div class="wrap%s" style="display:inline-block;padding-right:1.25em">%s</div></div>',
s = mw.html.create():wikitext(s .. ' ')
args[1],
args[3] and ' plainlist' or '',
if args[3] then
s:tag('br'):done()
args[3] and '\n* ' .. table.concat(args, '\n* ', 2) .. '\n'
end
or args[2]
s:tag(args[3] and 'div' or 'span')
)
:addClass('nowrap')
or args[1]
: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
end


function p.main(frame)
function p.main(frame)
-- mw.clone makes table.concat possible
return p._main(mw.clone(frame:getParent().args))
return p._main(mw.clone(frame:getParent().args))
end
end

Revision as of 08:25, 23 January 2020

local p = {}

function p._main(args)
	local s = args[1]
	if args[2] then
		s = mw.html.create():wikitext(s .. ' ')
		if args[3] then
			s:tag('br'):done()
		end
		s: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