[Templates] Retrieve stack value having '.' in the key
Hai Pham
hpham@re-trac.com
Mon, 18 Sep 2006 09:15:11 -0500
Thanks guy. Guess I will have to work around the limitation then.
-----Original Message-----
From: templates-admin@template-toolkit.org
[mailto:templates-admin@template-toolkit.org] On Behalf Of Paul Seamons
Sent: September 16, 2006 11:33 PM
To: templates@template-toolkit.org
Subject: Re: [Templates] Retrieve stack value having '.' in the key
> Neither of those works for me in 2.14. Is this new to 2.15 maybe?
>
> -- Josh
Hmm guess I assumed to much. I've done that very thing with strings in TT2
all the time. Doing a little testing we get the following:
perl -e 'use Template; Template->new->process(\qq{([% n="a b"; \$n %])([%
\${"a b"} %])\n},{"a b"=>"z"})'
(z)(z)
perl -e 'use Template; Template->new->process(\qq{([% n="a!\@#%^&*()b";
\$n %])([% \${"a!\@#%^&*()b"} %])\n},{"a!\@#%^&*()b"=>"z"})'
(z)(z)
perl -e 'use Template; Template->new->process(\qq{([% n="a.b"; \$n %])([%
\${"a.b"} %])\n},{"a.b"=>"z"})'
()()
perl -e 'use CGI::Ex::Template; CGI::Ex::Template->new->process(\qq{([%
n="a.b"; \$n %])([% \${"a.b"} %])\n},{"a.b"=>"z"})'
(z)(z)
So I was right and wrong. The notation I gave works very well in TT2 - so
long as you don't embed periods. I don't know what is going on in the
internals - but it seems sort of silly that only the period has issues.
Once
a name is looked up, it should be able to be used to access the stash
directly. And all names do - just don't include the period.
So - I'm afraid my help on the original question is no help at all.
Paul Seamons