[Templates] Retrieve stack value having '.' in the key

Josh Rosenbaum josh@infogears.com
Fri, 15 Sep 2006 15:50:30 -0600


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=20
> retrieve the value of key 'b' in hash a, which leads to wrong output. I=
s=20
> there anyway to escape it to fetch the correct value? Or is there anywa=
y=20
> 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=
ual_Methods

-- Josh