模組:沙盒/Sunny00217/LetParseLikeInTemplate
模块文档[创建]
您可能想要创建本Scribunto模块的文档。 编者可以在本模块的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 请在/doc子页面中添加分类。本模块的子页面。 |
return {
[''] = function (frame)
local root = frame.args.root
local ns10prexfix = frame.args.ns10prefix or 'Template:'
local q = mw.text.unstripNoWiki(frame.args[1])
q:gsub('{{([^<>%[%]{}%|%=}]+)([%|}])', function (n, p)
s, t = pcall(mw.title.new, n)
if not s or not t then
return '{{<kill />' .. n .. p
end
if t.namespace == 0 and n:match('^%:') then
return '{{' .. root .. ns10prexfix .. t.fullText .. p
else
return '{{' .. root .. t.fullText .. p
end
end)
return frame:preprocess(q:gsub('<kill />', ''))
end
}