Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Templating algorithm - pass in variables vs callback?

by Thilosophy (Curate)
on Mar 01, 2005 at 03:14 UTC ( [id://435267]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Templating algorithm - pass in variables vs callback?
in thread Templating algorithm - pass in variables vs callback?

Actually, HTML::Template allows you to pass in subroutines which will get called to get the parameter values:
# 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' });
However, since these subroutines cannot be parameterized from within the template, I am not sure how much use this is.

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/ )

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://435267]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-03-29 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found