Module:Page: Difference between revisions

Content deleted Content added
Darklama (talk | contribs)
simplify and fix pageid passing
Darklama (talk | contribs)
return error msg if title:field fails instead of passing "" for all parameters by default as untended results can happen
Line 24:
local interwiki=args.interwiki or pargs.interwiki or "";
local nowiki=args.nowiki or pargs.nowiki or false;
local page=args.page or args[1] or pargs.page or pargs[1] or "";
local id= tonumber( args.id or pargs.id );
local pn = { "", "", "", "", "", "", "", "", "" };
local title -- holds the result of the mw.title.xxx call
for i = 1,9 do pn[i] = args['p'..i] or pargs['p'..i] or ""; end
if not id and not mw.ustring.match( page, '%S' ) then page = nil; end
Line 48:
end
local result, success = title[field];
if type(result) == "function" then
success, result = resultpcall( result, title, unpack(pn) );
if nowikinot and result ~= nilsuccess then
return mw.textustring.nowikiformat("error: tostring(failed resultto title:%s(%s)", field, table.concat(pn, ',' ));
elseif result == nil or result == false then
return "";
else
return tostring(result);
end
end
if nowiki and result ~= nil then
return mw.text.nowiki( tostring( result ) );
else
return tostring(result or "");