وحدة:DemoTemplate4
توثيق الوحدة [أنشئ] [محو الاختزان][استخدامات] [قوالب]
require('strict')
local newBuffer = require('Module:OutputBuffer')
local mt = {}
function mt.__index(t, title)
return function(frame)
local line = ''
--if frame.args.demonewline and frame.args.demonewline ~= '' then line = '' end
local getBuffer, print, printf = newBuffer()
printf('{{%s \n', title)
local ipairsArgs = {}
for k, v in ipairs(frame.args) do
if string.find(v, '=', 1, true) then
break
end
ipairsArgs[k] = true
v = mw.text.trim(v)
printf('|%s ' .. line, v)
end
for k, v in pairs(frame.args) do
if k ~= 'demotitle' and k ~= 'demonewline' then
if not ipairsArgs[k] then
v = mw.text.trim(v)
printf('|%s=%s ' .. line, string.gsub(k, '=', '{{=}}'), v)
end
end
end
print('\n}}')
local temptitle = ''
if frame.args.demotitle and frame.args.demotitle ~= '' then
temptitle = "|+ '''" .. frame.args.demotitle .. "'''\n"
end
local buffer = getBuffer()
-- rather than calling expandTemplate with the title and args we have, call preprocess, so that our code example will always match our output, even in the cases of pipes or other things we should have escaped but didn't
return '{| class="wikitable" style="border-color:#ddd;"\n'
.. temptitle
.. "| '''توصيف''' \n"
.. '|' .. frame:extensionTag('syntaxhighlight', buffer, { lang = 'html+handlebars' })
.. '\n|-\n'
.. "| '''يظهر''' \n"
.. '| <span style="">' .. frame:preprocess(buffer) .. '</span>\n'
.. '\n|}'
end
end
return setmetatable({}, mt)