Difference between revisions of "Module:Based on/sandbox"

From blackwiki
Jump to navigation Jump to search
blackwiki>Nardog
blackwiki>Nardog
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()
if args[3] then
+
:wikitext(s .. ' ')
s:tag('br'):done()
+
:tag('br')
end
 
s:tag(args[3] and 'div' or 'span')
 
:addClass('nowrap')
 
:tag('span')
 
:css('vertical-align', 'top')
 
:wikitext('by ')
 
 
:done()
 
:done()
 
:tag(args[3] and 'div' or 'span')
 
:tag(args[3] and 'div' or 'span')
:addClass('wrap')
+
:addClass('nowrap')
:addClass(args[3] and 'plainlist')
+
:tag('span')
:css('display', 'inline-block')
+
:css('vertical-align', 'top')
-- Prevents the text from spilling out
+
:wikitext('by ')
:css('padding-right', '1.25em')
+
:done()
:wikitext(args[3] and
+
:tag(args[3] and 'div' or 'span')
'\n* ' .. table.concat(args, '\n* ', 2) .. '\n'
+
:addClass('wrap')
or args[2])
+
: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()
 
:done()
:done()
 
 
end
 
end
 
return s
 
return s

Revision as of 08:29, 23 January 2020

Documentation for this module may be created at Module:Based on/sandbox/doc

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