Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Forcing context of dot operator in Template Toolkit

by agianni (Hermit)
on Oct 26, 2007 at 19:11 UTC ( [id://647471] : note . print w/replies, xml ) Need Help??


in reply to Forcing context of dot operator in Template Toolkit

Hey, so it turns out I got this working after all. There was a bug in my test that was forcing the object context. I missed the fact that the original author of the test had overridden my method to explicitly return an object all of the time :)

This is to say that now the template always pulls back the hashref instead of the object from Contextual::Return. This works fine for me since it is backwards compatibility from a hashref model that I'm looking for. So in the mean time, I have bi-directional flexibility in my controller code and access to hashrefs in my templates. I have accounted for this by creating entries in the hashref with names identical to the method accessors, so I can call:

foo.bar.baz

or

foo.get_baz

which both give me the same value, and while the later looks like a method call, it's actually just a hash entry. It's a total kludge, but that's all I'm after right now.

perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'