Content deleted Content added
Petr Matas (talk | contribs) Remove out-of-date content fork of /doc Tags: Mobile edit Mobile web edit |
clean for style; fix error per talk |
||
Line 2:
local result = { func(...) }
if not result[1] then
-- Return a string with error class detectable by #iferror.
return string.format(
'<span class="error">Error: %s(%s) failed</span>',
funcName,
table.concat({...}, ', ')
)
end
return unpack(result)
end
local function main(frame, field)
▲ if type(result) == "function" then
local success;▼
if type(result) == "function" then
if not success then▼
error(result, 0);▼
success, result = pcall( result, title, unpack(pn) )
▲ end
end
▲ return tostring(result or "");
end
return tostring(result or "")
end
local p = {}
-- main function does all the work
local meta = {}
function meta.__index(
return function(frame)
return main(frame, key)
Line 55 ⟶ 63:
function p.getContent(frame)
local args, pargs = frame.args, ( frame:getParent() or {} ).args or {}
local fmt = args.as or pargs.as or false
local text = main(frame, "getContent")
if not fmt then
return frame:preprocess( "<pre>" .. text .. "</pre>" )
end
fmt = mw.text.split( fmt, ", ?" )
for _, how in ipairs( fmt ) do
if how == "pre" then
|