Difference between revisions of "Module:Demo"

From MINR.ORG WIKI
(it works!)
Line 2: Line 2:
  
 
function p.main(frame)
 
function p.main(frame)
args = require('Module:Arguments').getArgs(frame, {
+
frame = frame:getParent() or frame
trim = false,
+
local code = mw.text.unstripNoWiki(frame.args[1])
removeBlanks = false
+
local template = frame:preprocess(mw.text.unstripNoWiki(frame.args[1]))
})
 
 
local br = ''
 
local br = ''
for k = 1, (args.br or 1) do
+
for k = 1, (frame.args.br or 1) do
 
br = br .. '<br>'
 
br = br .. '<br>'
 
end
 
end
return string.format('<pre%s>%s</pre>%s%s', args.style and string.format(" style='%s'", args.style) or '', mw.text.nowiki(args[1] or ''), br, args[1] or '')
+
return string.format('<div><pre%s>%s</pre>%s%s</div>', frame.args.style and string.format(" style='display:block;%s'", frame.args.style) or '', code, br, template)
 
end
 
end
  
 
return p
 
return p

Revision as of 18:55, 31 December 2014

Documentation for this module may be created at Module:Demo/doc

local p = {}

function p.main(frame)
	frame = frame:getParent() or frame
	local code = mw.text.unstripNoWiki(frame.args[1])
	local template = frame:preprocess(mw.text.unstripNoWiki(frame.args[1]))
	local br = ''
	for k = 1, (frame.args.br or 1) do
		br = br .. '<br>'
	end
	return string.format('<div><pre%s>%s</pre>%s%s</div>', frame.args.style and string.format(" style='display:block;%s'", frame.args.style) or '', code, br, template)
end

return p