Difference between revisions of "Module:Sandbox/BrandonXLF/2/example"

From blackwiki
Jump to navigation Jump to search
blackwiki>BrandonXLF
(Trying with frame:preprocess)
blackwiki>BrandonXLF
Line 2: Line 2:
  
 
function p.main (frame)
 
function p.main (frame)
+
local args = frame.args
local exampleNumber = frame.args.EXAMPLE
 
local code = frame.args.CODE
 
 
 
 
local arguments = {
 
local arguments = {
Line 20: Line 18:
 
}
 
}
 
 
local out = frame:preprocess('{{#invoke:Sandbox/BrandonXLF/2'..arguments[exampleNumber]..'}}')
+
local out = frame:preprocess('{{#invoke:Sandbox/BrandonXLF/2'..arguments[args.EXAMPLE]..'}}')
 
 
if code then
+
if args.code then
 
out = '<pre>'..out..'</pre>'
 
out = '<pre>'..out..'</pre>'
 
end
 
end

Revision as of 01:55, 2 January 2019

Documentation for this module may be created at Module:Sandbox/BrandonXLF/2/example/doc

local p = {}

function p.main (frame)
	local args = frame.args
	
	local arguments = {
		[1]  = '|main|item|, ',
		[2]  = '|main||, ||| and ',
		[3]  = '|main||, |&bull;|&bull;| and ',
		[4]  = '|main|x| & ',
		[5]  = '|main|x| & |item $i: ',
		[6]  = '|bulleted',
		[7]  = '|unbulleted',
		[8]  = '|horizontal',
		[9]  = '|ordered',
		[10] = '|commas',
		[11] = '|list',
	}
	
	local out = frame:preprocess('{{#invoke:Sandbox/BrandonXLF/2'..arguments[args.EXAMPLE]..'}}')
	
	if args.code then
		out = '<pre>'..out..'</pre>'
	end
	
	return out

end

return p