Module:Cargo

از ویکی داد
پرش به ناوبری پرش به جستجو

local p = {}

function p.query(frame)

   local args = frame.args
   local results = mw.ext.cargo.query(
       args.tables,
       args.fields,
       {
           where = args.where,
           orderBy = args.orderBy,
           limit = args.limit or 100
       }
   )
   if not results or #results == 0 then
       return args.default or 
   end
   local output = {}
   if args.intro then
       table.insert(output, args.intro)
   end
   for _, row in ipairs(results) do
       table.insert(
           output,
           mw.getCurrentFrame():expandTemplate{
               title = args.template,
               args = row
           }
       )
   end
   if args.outro then
       table.insert(output, args.outro)
   end
   return table.concat(output, args.delimiter or )

end

return p