模块:Utils:修订间差异

添加287字节 、​ 2024年2月14日 (星期三)
无编辑摘要
无编辑摘要
Lz讨论 | 贡献
无编辑摘要
 
(未显示同一用户的5个中间版本)
第2行: 第2行:


function p.foreach(frame)
function p.foreach(frame)
     local template = frame.args[1]:gsub('\\n', '\n')
     local template = frame.args[1]:gsub('\n$', '')
    template = template:gsub('\\n', '\n')
    template = template:gsub('%(%(!%)%)', '|')
     local ret = ''
     local ret = ''
     for i, arg in ipairs(frame.args) do
     for i, arg in ipairs(frame.args) do
    arg = arg:gsub('\n$', '')
         if i > 1 and arg ~= '' then
         if i > 1 and arg ~= '' then
             local text = template:gsub('%(%(%(1%)%)%)', arg)
             local text = template:gsub('%(%(%(1%)%)%)', arg)
第10行: 第13行:
         end
         end
     end
     end
     return frame:preprocess(ret)
     return ret
end
 
function p.inherit_args(frame)
    local template = frame.args[1]
    local parent = frame:getParent()
    return frame:expandTemplate{title = template, args = parent.args}
end
end


function p.d()
function p.d()
     local frame = {
     local frame = {
         args = { 'hello (((1)))\n', 'x', 'y', 'z' }
         args = { '((!))hello (((1)))\n', 'x\n', 'y\n', 'z' }
     }
     }
     local r = p.foreach(frame)
     local r = p.foreach(frame)
2,088

个编辑