可在模块:Example/doc创建此模块的帮助文档
local module = {}
local getArgs = require('Module:Arguments').getArgs
function _main(args, frame)
local codes = args[1]
local isPrint = args[2] == 'print'
local preTag = frame:extensionTag('pre', codes)
local executedResult = frame:preprocess(
mw.text.decode(
mw.text.unstripNoWiki(codes)
)
)
if isPrint then
return preTag..mw.text.trim(executedResult)
else
frame:callParserFunction('#vardefine', 'example-view', executedResult)
return preTag
end
end
function module.main(frame)
local args = getArgs(frame)
return _main(args, frame)
end
return module