Module:Template wrapper: Difference between revisions
Content deleted Content added
Johnrdorazio (talk | contribs) m 1 revision imported |
Add uncopyable line break opportunities to documentation mode |
||
Line 249: | Line 249: | ||
]] |
]] |
||
⚫ | |||
⚫ | |||
⚫ | |||
template = _main (frame, args, true); -- get default and live parameters and the name of the listed template |
|||
⚫ | |||
⚫ | |||
⚫ | |||
return error_msg; -- emit error message and abandon if template name not present |
|||
⚫ | |||
⚫ | |||
return error_msg; -- emit error message and abandon if template name not present |
|||
end |
end |
||
if do_link then |
|||
template = ('[[%s|%s]]'):format(frame:expandTemplate{ title='Transclude', args = {template} }, template) |
|||
return frame:preprocess (table.concat ({'<code style="color:inherit; background:inherit; border:none;"><nowiki>{{', template, ' |', table.concat( args, ' |' ), '}}</nowiki></code>'})); -- render the template |
|||
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 |
|||
return frame:preprocess(table.concat({ |
|||
'<code style="color:inherit; background:inherit; border:none;">{{', |
|||
template, |
|||
('<wbr><nowiki>|%s</nowiki>'):rep(#args):format(unpack(args)), '}}</code>'})); -- render the template |
|||
end |
end |
||
local function link (frame) |
|||
return list(frame, true) |
|||
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 >------------------------------------------ |
||
Line 267: | Line 279: | ||
return { |
return { |
||
link = link, |
|||
list = list, |
list = list, |
||
wrap = wrap, |
wrap = wrap, |