2,088
个编辑
(Created page with "local p = {} function p.for_each(frame) local template = frame.args[1]:gsub('\\n', '\n') local ret = '' for i, arg in ipairs(frame.args) do if i > 1 then local text = template:gsub('%(%(%(1%)%)%)', arg) ret = ret .. text end end return frame:preprocess(ret) end function p.d() local frame = { args = { 'hello (((1)))\n', 'x', 'y', 'z' } } local r = p.for_each(frame) mw.log(r) end return p") |
无编辑摘要 |
||
第5行: | 第5行: | ||
local ret = '' | local ret = '' | ||
for i, arg in ipairs(frame.args) do | for i, arg in ipairs(frame.args) do | ||
if i > 1 then | if i > 1 and arg ~= '' then | ||
local text = template:gsub('%(%(%(1%)%)%)', arg) | local text = template:gsub('%(%(%(1%)%)%)', arg) | ||
ret = ret .. text | ret = ret .. text |