in reply to Re^2: Templating algorithm - pass in variables vs callback?
in thread Templating algorithm - pass in variables vs callback?
However, since these subroutines cannot be parameterized from within the template, I am not sure how much use this is.# with a subroutine reference that gets called to get the value # of the scalar. The sub will recieve the template object as a # parameter. $self->param(PARAM => sub { return 'value' });
I'd love to be able to do the following (which is not supported, however):
$tmpl->param( blah => sub { my ($a, $b, $c) = @_; return 'something'; } ); <tmpl_var name='blah(1,2,3)'>
I think HTML::Template should have some simple kind of expression language that would allow you to these things, as well as drilling down into hashes and arrays, accessing objects (which should eliminate the need for callbacks), and doing simple arithmetics .
HTML::Template::Expr is doing some of these things already.
(Like everyone else, I have started to implement my own templating system with these ideas in mind. It is mostly a project to teach myself about Parrot, but if you are interested: http://budgie.sourceforge.net/ )
|
|---|