Module:CargoQuery: Difference between revisions

308 bytes added ,  01:13, 2 September 2020
m
no edit summary
mNo edit summary
mNo edit summary
Line 157: Line 157:
         local splitargs = {}
         local splitargs = {}
for a, b in ipairs(args) do
for a, b in ipairs(args) do
     splitargs[a] = util_args.splitNamedArgs(b, '%s*;%s*')
     splitargs[a] = util_args.splitNamedArgs(frame:preprocess(b), '%s*;%s*')
end
end


Line 167: Line 167:
resulttbl = util_table.merge(result[1], result[2])
resulttbl = util_table.merge(result[1], result[2])
local tbl = {}
local tbl = {}
template = frame:preprocess(args['template'] or '')
delimiter = frame:preprocess(args['delimiter'] or '')
if template == nil or template == '' then
    error('A template must be specified!')
end
for i, row in ipairs(resulttbl) do
for i, row in ipairs(resulttbl) do
row.index = i
row.index = i
tbl[#tbl+1] = frame:expandTemplate{ title = args['template'], args = row }
tbl[#tbl+1] = frame:expandTemplate{ title = args['template'], args = row }
end
end
 
        if #tbl == 0 then
          return frame:preprocess(args['default'] or 'no results')
        end
local intro = frame:preprocess(args['intro'] or '')
local intro = frame:preprocess(args['intro'] or '')
local outro = frame:preprocess(args['outro'] or '')
local outro = frame:preprocess(args['outro'] or '')
return intro  .. table.concat(tbl, args['delimiter'] or '') .. outro
return intro  .. table.concat(tbl, delimiter) .. outro


end
end


return p
return p