Jump to content

Module:Based on/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Nardog (talk | contribs) at 08:25, 23 January 2020. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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