Fellows
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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|