وحدة:DemoTemplate3

من أرابيكا، الموسوعة الحرة
اذهب إلى التنقل اذهب إلى البحث

require('Module:No globals')

local newBuffer = require('Module:OutputBuffer')
local mt = {}

function mt.__index(t, title)
	return function(frame)
		local false_args = {
			["_sandbox_"] = "",
			["_compare_"] = "",
			["demotitle"] = "",
			["_dir_"] = "",
			["_demonewline_"] = "",
			["demonewline"] = "",
			["syntaxhighlight"] = ""
		}
		local line = '\n'
		if frame.args.demonewline and frame.args.demonewline ~= '' then line = '' end
		local getBuffer, print, printf = newBuffer()
		printf('{{%s ' .. line, title)
		local ipairsArgs = {}
		for k,v in ipairs(frame.args) do
			if string.find(v, '=', 1, true) then
				break
			end
			ipairsArgs[k] = true
			printf('|%s ' .. line, v)
		end
		for k,v in pairs(frame.args) do
			if not false_args[k] and not ipairsArgs[k] then
				if not ipairsArgs[k] then
					printf('|%s=%s ' .. line, string.gsub(k, '=', '{{=}}'), v)
				end
			end
		end
		print('}}')
		local temptitle = ''
		if frame.args.demotitle and frame.args.demotitle ~= '' then
			temptitle = "|+ '''" .. frame.args.demotitle .. "'''\n"
		end 
		local buffer = getBuffer()
		return '{| style="table-layout:fixed; width:100%; margin-top:0;margin-left:0; border-width:medium; padding:0; "\n'
			.. temptitle 
			.. '!scope="col" style="width:50%;"| توصيف ||scope="col" style="width:50%;"| يظهر\n|-\n'
			
			.. '\n|style="width:50%; background:#f9f9f9;border-width:1px;border-style:solid solid none solid;'
			..' border-color:#ddd; vertical-align:top;"| '
			
			.. frame:extensionTag('syntaxhighlight', buffer, {lang = 'html+handlebars'})
			
			.. '\n|style="width:50%; background:#f9f9f9;border-width:1px;border-style:solid solid none solid;'
			..' border-color:#ddd; padding:5px; vertical-align:top;"| '
			.. '<span style="">' .. frame:preprocess(buffer) ..'</span>\n'
			..'|-\n|style="width:50%; border-width:1px;border-style:solid none none none; border-color:#ddd; padding:5px; vertical-align:top;"| \n'
			..'|style="width:50%; border-width:1px;border-style:solid none none none;border-color:#ddd; padding:5px; vertical-align:top;"| \n|}'
	end
end

return setmetatable({}, mt)