پودمان:Template wrapper: تفاوت میان نسخه‌ها

۳۴۳ بایت اضافه‌شده ،  ‏۲۱ نوامبر ۲۰۲۲
جز
۱ نسخه واردشده
(صفحه‌ای تازه حاوی «require('Module:No globals'); local error_msg = '<span style=\"font-size:100%\" class=\"error\"><code style=\"color:inherit; border:inheri...» ایجاد کرد)
 
جز (۱ نسخه واردشده)
 
(یک نسخهٔ میانی ویرایش شده توسط یک کاربر دیگر نشان داده نشد)
خط ۱: خط ۱:
require('Module:No globals');
require('strict');


local error_msg = '<span style=\"font-size:100%\" class=\"error\"><code style=\"color:inherit; border:inherit; padding:inherit;\">&#124;_template=</code> missing or empty</span>';
local error_msg = '<span style=\"font-size:100%\" class=\"error\"><code style=\"color:inherit; border:inherit; padding:inherit;\">&#124;_template=</code> missing or empty</span>';
خط ۲۴۹: خط ۲۴۹:
]]
]]


local function list(frame, do_link)
local args = {}; -- table of default and live parameters and their values to be passed to the listed template
local template; -- the name of the listed template


local function list (frame)
template = _main (frame, args, true); -- get default and live parameters and the name of the listed template
local args = {}; -- table of default and live parameters and their values to be passed to the listed template
if not template then -- template name is required
local template; -- the name of the listed template
return error_msg; -- emit error message and abandon if template name not present
 
end
template = _main (frame, args, true); -- get default and live parameters and the name of the listed template
if do_link then
if not template then -- template name is required
template = ('[[%s|%s]]'):format(frame:expandTemplate{ title='Transclude', args = {template} }, template)
return error_msg; -- emit error message and abandon if template name not present
end
table.sort(args)
for i = 1, #args do
local stripped = args[i]:match('^' .. i .. '=([^=]*)$')
if stripped then args[i] = stripped else break end
end
end
return frame:preprocess(table.concat({
'<code style="color:inherit; background:inherit; border:none;">&#123;&#123;',
template,
('<wbr><nowiki>|%s</nowiki>'):rep(#args):format(unpack(args)), '&#125;&#125;</code>'})); -- render the template
end


return frame:preprocess (table.concat ({'<code style="color:inherit; background:inherit; border:none;"><nowiki>{{', template, ' |', table.concat( args, ' |' ), '}}</nowiki></code>'})); -- render the template
local function link (frame)
return list(frame, true)
end
end


--[[--------------------------< E X P O R T E D  F U N C T I O N S >------------------------------------------
--[[--------------------------< E X P O R T E D  F U N C T I O N S >------------------------------------------
خط ۲۶۷: خط ۲۷۹:


return {
return {
link = link,
list = list,
list = list,
wrap = wrap,
wrap = wrap,
};
};