[Templates] Retrieve stack value having '.' in the key
Josh Rosenbaum
josh@infogears.com
Fri, 15 Sep 2006 17:07:35 -0600
Neither of those works for me in 2.14. Is this new to 2.15 maybe?
-- Josh
Paul Seamons wrote:
> You can do this:
>=20
> [% name =3D "a.b" ; $name %]
>=20
>=20
> There may be another way also.
> I don't remember if TT2 supports it (CGI::Ex::Template does) but I thin=
k TT2=20
> does support the following:
>=20
> [% ${"a.b"} %]
>=20
> Hope that helps.
>=20
> Paul
>=20
> 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 any=
way
>>> 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_V=
irtua
>> l_Methods
>>
>> -- Josh
>>
>> _______________________________________________
>> templates mailing list
>> templates@template-toolkit.org
>> http://lists.template-toolkit.org/mailman/listinfo/templates
>=20
> _______________________________________________
> templates mailing list
> templates@template-toolkit.org
> http://lists.template-toolkit.org/mailman/listinfo/templates