Content deleted Content added
Petr Matas (talk | contribs) Remove out-of-date content fork of /doc Tags: Mobile edit Mobile web edit |
Add support for tables |
||
(8 intermediate revisions by 4 users not shown) | |||
Line 1:
local
local result = { func(...) }▼
local function main(frame, field)▼
if not result[1] then▼
end
return unpack(result)▼
end▼
▲function main(frame, field)
▲ local args, pargs = frame.args, ( frame:getParent() or {} ).args or {};
▲ local makeTitle=args.makeTitle or pargs.makeTitle or "";
▲ local namespace=args.namespace or pargs.namespace or "";
result = mw.text.listToText(result)
▲ local fragment=args.fragment or pargs.fragment or "";
▲ end
▲ local interwiki=args.interwiki or pargs.interwiki or "";
▲ local page=args.page or args[1] or pargs.page or pargs[1] or "";
▲ local id= tonumber( args.id or pargs.id );
▲ 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]; end
▲ if not id and not mw.ustring.match( page, '%S' ) then page = nil; end
▲ if id then
▲ title = callAssert(mw.title.new, 'mw.title.new', id);
▲ elseif not page then
▲ title = callAssert(mw.title.getCurrentTitle, 'getCurrentTitle');
▲ elseif makeTitle then
▲ title = callAssert(mw.title.makeTitle, 'makeTitle', namespace, page, fragment, interwiki);
▲ else
▲ title = callAssert(mw.title.new, 'mw.title.new', page, namespace);
▲ if type(result) == "function" then
▲ success, result = pcall( result, title, unpack(pn) );
end
-- handle all errors in main
▲local p = {};
main = require('Module:Protect')(main)
-- main function does all the work
local meta = {}
function meta.__index(
return function(frame)
return main(frame, key)
Line 55 ⟶ 50:
function p.getContent(frame)
local args, pargs = frame.args, ( frame:getParent() or {} ).args or {}
local fmt = args.as or pargs.as or
local text = main(frame, "getContent")
fmt = mw.text.split( fmt, ", ?" )
for _, how in ipairs( fmt ) do
if how == "pre" then
|