monsieur_champs has asked for the wisdom of the Perl Monks concerning the following question:

I'm having big trouble with TT2 and a template that needs to implement data filters. As the files I wrote are big and kind of senseless, I'm posting just the bytes that matter.

[% # # Template "tbl_pessoa_fisica.tt2" # USE pessoa_fisica = Class('reciclar::cdbi::pessoa_fisica'); # The values in the FOREACH list are all variable names # provided by my template renderization engine. It works # receiving some parameters and is well-tested, as I've # used it unmodified in many projects before this. # FOREACH item = [ "id", "primeiro_nome", "sobrenome", "display_name" +, "cep", "nome_logradouro", "numero", "cidade", "estado", "ddd", "tel +efone" ]; # IF ${$item}.defined(); THEN; ### doesn't work for me # IF ${$item} != ""; THEN; ### doesn't work for me IF ${$item}; THEN; ## Should do the same of perl's "$params{$item} = ${$item};" params.$item = ${$item}; END; END; ### Here is my problem: ### params.keys() never returns a key list (hash is empty!), ### despite what I pass as parameters. IF params.keys(); THEN; list_pessoa_fisica = pessoa_fisica.search_where( params, { logic => "and" } ); ELSE; list_pessoa_fisica = pessoa_fisica.retrieve_all(); END; %]

Things put short, I need to construct a parameter list based on a bunch of variables that I'll receive inside the template from the Perl script running it. I can't accept blank and undef() values into this hash, so I can pass it as my Class::DBI::AbstractSearch::search_where() parameter list.

My problem is that doesn't matter what test I use, nor what values are being passed into the scritp, I just can't build the hash. Any fellow monk have any past experience, tips, tricks, suggestions or code to offer?