[Templates] Retrieve stack value having '.' in the key
Paul Seamons
mail@seamons.com
Fri, 15 Sep 2006 16:45:52 -0600
You can do this:
[% name =3D "a.b" ; $name %]
There may be another way also.
I don't remember if TT2 supports it (CGI::Ex::Template does) but I think TT=
2=20
does support the following:
[% ${"a.b"} %]
Hope that helps.
Paul
On Friday 15 September 2006 3:50 pm, Josh Rosenbaum wrote:
> Hai Pham wrote:
> > Let's say we have this variable stack:
> > VARIABLES =3D> { version =3D> 3.14,
> > =91a.b' =3D> 'Sahara', },
> > If I try to access the key 'a.b' using [% a.b %], TT will try to
> > retrieve the value of key 'b' in hash a, which leads to wrong output. Is
> > there anyway to escape it to fetch the correct value? Or is there anyway
> > to access the stash directly to invoke the get function?
>
> I know of no way to do this, but would be interested in hearing about it =
if
> there was.
>
> In the mean time why not just send this in another variable like:
> crazy_var_names =3D> {
> 'a.b' =3D> 'Sahara'
> }
>
> Then use crazy_var_names.item('a.b').
>
> More on item vmethod here:
> http://www.template-toolkit.org/docs/plain/Manual/VMethods.html#Hash_Virt=
ua
>l_Methods
>
> -- Josh
>
> _______________________________________________
> templates mailing list
> templates@template-toolkit.org
> http://lists.template-toolkit.org/mailman/listinfo/templates