Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Templating algorithm - pass in variables vs callback?

by sgifford (Prior)
on Mar 01, 2005 at 06:23 UTC ( [id://435293]=note: print w/replies, xml ) Need Help??


in reply to Templating algorithm - pass in variables vs callback?

When faced with a similar problem, I found the best approach was to ask the template for a list of all variables it was going to use, pull in just those values to a hashref, then display the template with that hashref. For an SQL backend, this mostly meant adding in the right tables and columns to a SELECT statement.

This was using custom template code; not sure whether your system will allow this or not, but it seems like pretty basic functionality.

As for the popularity of the hashref approach, I think it's intuitive, and it's also quite hard to screw up from a security perspective. It seems like callbacks would be much harder to get right in this way; it seems like a small mistake or oversight on the part of the template code's author could easily let the template call arbitrary code.

  • Comment on Re: Templating algorithm - pass in variables vs callback?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-25 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found