Module:User:Litzsch/Sandbox

local p = {} local cargo_query = mw.ext.cargo.query local getArgs = require( 'Module:Arguments' ).getArgs

local prefix = { ['_'] = true, ['!'] = true }

function p.main( frame ) local args = getArgs( frame )

local table = args._table local where = args._where

local template_args = { structure = hidden } for template_key, cargo_key in pairs( args ) do   -- Don't pass prefixed keys to the template. local first_char = string.sub( template_key, 0, 1 ) if not prefix[first_char] then local value = cargo_query( table, cargo_key, {       where = where,      } )[1][cargo_key]

if value ~= '' then template_args[template_key] = value end end end

for key, value in pairs( args ) do   if string.sub( key, 0, 1 ) == '!' then local template_key = string.sub( key, 2 ) template_args[template_key] = value end end

return frame:expandTemplate{ title = args._template, args = template_args } end

return p