Content deleted Content added
clean for style; fix error per talk |
Add support for tables |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1:
local
local function main(frame, field)
local args, pargs = frame.args, ( frame:getParent() or {} ).args or {}
local makeTitle=args.makeTitle or pargs.makeTitle
local namespace=args.namespace or pargs.namespace or ""
local fragment=args.fragment or pargs.fragment or ""
Line 34 ⟶ 23:
else
title = callAssert(mw.title.new, 'mw.title.new', page, namespace)
if type(title) ~= 'table' then▼
end
local result = title[field]
if type(result) == "function" then
▲ success, result = pcall( result, title, unpack(pn) )
result = mw.text.listToText(result)
end
return tostring(result or "")
end
-- handle all errors in main
main = require('Module:Protect')(main)
local p = {}
Line 64 ⟶ 51:
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, ", ?" )
|