Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Template reserved words

by packetstormer (Monk)
on Jan 22, 2013 at 21:15 UTC ( #1014791=perlquestion: print w/ replies, xml ) Need Help??
packetstormer has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks
Hopfully this is an easy one but I can't figure it.
How would one go about displaying a hash in a Tempalte file when the hash key is a reserved word in Template?
e.g

[% FOR line IN xml %] [% line.size.value %] [% END %]

It seems both "size" and "value" are reserved words in Template. I did try "ANYCASE => 0" but it doesn't do what I need. Anyone?

Comment on Template reserved words
Download Code
Replies are listed 'Best First'.
Re: Template reserved words
by kennethk (Abbot) on Jan 22, 2013 at 21:43 UTC
    You can get around the unfortunate choice of keys by using Variable Interpolation:
    [% FOR line IN xml %] [% size_key = 'size'; value_key = 'value'; line.$size_key.$value_key %] [% END %]

    This assumes you are using Template::Toolkit, of course.


    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: Template reserved words
by Anonymous Monk on Jan 22, 2013 at 23:42 UTC
Re: Template reserved words
by LanX (Canon) on Jan 22, 2013 at 21:39 UTC
      I am using Template -> http://template-toolkit.org/

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1014791]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2015-07-30 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls