Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (6)
    As of 2017-11-23 21:22 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (339 votes). Check out past polls.