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

From blackwiki
Jump to navigation Jump to search
blackwiki>Nardog
m
m (8 revisions imported)
 
(6 intermediate revisions by one other user not shown)
Line 3: Line 3:
 
function p._main(args)
 
function p._main(args)
 
local s = args[1]
 
local s = args[1]
if args[3] then
+
if args[2] then
local h = mw.html.create('ul')
+
s = mw.html.create()
for i, v in ipairs(args) do
 
if i ~= 1 then
 
h:tag('li'):wikitext(v):done()
 
end
 
end
 
h = mw.html.create()
 
 
:wikitext(s .. ' ')
 
:wikitext(s .. ' ')
 
:tag('br')
 
:tag('br')
 
:done()
 
:done()
:tag('span')
+
:tag(args[3] and 'div' or 'span')
:css('vertical-align', 'top')
+
:addClass('nowrap')
:wikitext('by ')
+
: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()
 
:done()
:tag('div')
 
:addClass('plainlist')
 
:css('display', 'inline-block')
 
:node(h)
 
:allDone()
 
s = h
 
elseif args[2] then
 
s = s .. ' <br />by ' .. args[2]
 
 
end
 
end
 
return s
 
return s
Line 31: Line 30:
  
 
function p.main(frame)
 
function p.main(frame)
return p._main(frame:getParent().args)
+
-- mw.clone makes table.concat possible
 +
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