henk wrote:
Meanwhile, in the template
   [% fortytwo %]  evaluates to 42, as expected.
However,
   [% mymethod %] fails. But
   [% me.mymethod %] yields 'hi'.

but I feel I should not need to qualify the method with the 'me' trick, I
never see it in examples. So how should I set things up to be able to
directly call the methods of the object that is passed as the value
parameter to process()?
AFAIK you can't do that, that's why you never see the examples. TT expects bare 'methods' to be called via a code reference, for instance:

Code:

$template->process( \$text, { mymethod => \&mymethod } );

Template:

Calling mymethod: [% mymethod() %]

The fact that your 'fortytwo' example worked is a coincidence -- if your object were implemented as a blessed arrayref it wouldn't have worked at all. I think typing a few extra characters (me.mymethod vs mymethod) shouldn't be too much of a burden ;-)

Chris

--
Chris Winters ([EMAIL PROTECTED])
Building enterprise-capable snack solutions since 1988.


_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to