模块:CallPFCorrect2

来自希服维基

可在模块:CallPFCorrect2/doc创建此模块的帮助文档

local p = {}
function p.test(frame)
    local parent = frame:getParent()
    if not parent or not parent.callParserFunction then return "no_callPF" end

    local results = {}

    -- Call with single string argument
    local ok1, out1 = pcall(parent.callParserFunction, parent, "expr", "1+1")
    results[1] = "expr_1arg=" .. tostring(ok1) .. ":" .. tostring(out1)

    -- Call with separate argument (string)
    local ok2, out2 = pcall(parent.callParserFunction, parent, "expr", "1", "+", "1")
    results[2] = "expr_3arg=" .. tostring(ok2) .. ":" .. tostring(out2)

    -- Try with "mw.ext.ParserFunctions.expr" style name
    local ok3, out3 = pcall(parent.callParserFunction, parent, "mw.ext.ParserFunctions.expr", "1+1")
    results[3] = "mw_ext_expr=" .. tostring(ok3) .. ":" .. tostring(out3)

    -- Try some known PHP callbacks
    local ok4, out4 = pcall(parent.callParserFunction, parent, "ParserFunctions_expr", "1+1")
    results[4] = "PF_expr=" .. tostring(ok4) .. ":" .. tostring(out4)

    return table.concat(results, " | ")
end
return p