Module:CargoQuery: Difference between revisions

6 bytes added ,  03:00, 2 September 2020
m
no edit summary
mNo edit summary
mNo edit summary
Line 158: Line 158:
local splitargs = {}
local splitargs = {}
for a, b in ipairs(args) do
for a, b in ipairs(args) do
    splitargs[a] = util_args.splitNamedArgs(frame:preprocess(b), '%s*;%s*')
    splitargs[a] = util_args.splitNamedArgs(frame:preprocess(b), '%s*;%s*')
end
end
template = frame:preprocess(args['template'] or '')
template = frame:preprocess(args['template'] or '')
delimiter = frame:preprocess(args['delimiter'] or '')
delimiter = frame:preprocess(args['delimiter'] or '')
if template == nil or template == '' then
if template == nil or template == '' then
    error('A template must be specified!')
    error('A template must be specified!')
end
end
splitargs['default'] = ''
splitargs['default'] = ''
Line 169: Line 169:
local result = {}
local result = {}
for a, b in ipairs(splitargs) do
for a, b in ipairs(splitargs) do
    tempresult = p.query(b)
    tempresult = p.query(b)
    if tempresult ~= nil and tempresult ~= '' then
    if tempresult ~= nil and tempresult ~= '' then
        result[#result+1] = p.query(b)
        result[#result+1] = p.query(b)
    end
    end
end
end
resulttbl = util_table.mergeArrays(nil, unpack(result))
resulttbl = util_table.mergeArrays(nil, unpack(result))