Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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?


In reply to Trouble building hashes from value lists inside a TT2 template by monsieur_champs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-16 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found