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

From blackwiki
Jump to navigation Jump to search
blackwiki>Nardog
m (8 revisions imported)
 
(4 intermediate revisions by one other user not shown)
Line 2: Line 2:
  
 
function p._main(args)
 
function p._main(args)
return args[3] and string.format(
+
local s = args[1]
'%s <br /><span style="vertical-align:top">by </span><div class="plainlist" style="display:inline-block">\n* %s</div>',
+
if args[2] then
args[1],
+
s = mw.html.create()
table.concat(args, '\n* ', 2)
+
:wikitext(s .. ' ')
)
+
:tag('br')
or args[2] and string.format(
+
:done()
'%s <span style="display:inline-block">by %s</span>',
+
:tag(args[3] and 'div' or 'span')
args[1],
+
:addClass('nowrap')
args[2]
+
:tag('span')
)
+
:css('vertical-align', 'top')
or args[1]
+
: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
  
 
return p
 
return p

Latest revision as of 13:22, 26 September 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