Mark Wagner wrote:
In perl one accesses a value in a hash reference like so:

$a->{'foo'}.

For the Template Toolkit that would be written like so:

a.foo

However this seems to place the restriction that keys must follow the
naming rules for variables (alphanumeric + _, leading char alpha).

I'm running into many situations where the key contains other characters
such as " " or "-". What is the best way to handle these? I hope it isn't:

bar = "key with spaces-n-dashes"
a.$bar

http://www.template-toolkit.org/pipermail/templates/2006-October/009062.html

Quoting Paul: "So - for your case [% foo.${"bar baz"} %] would work as well."

There's also the item vmethod:
http://www.template-toolkit.org/pipermail/templates/2006-October/009061.html
[% hash.item('foo') %]  # same as hash.foo

-- josh

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to