Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Two tips for developing with HTML::Template

by dws (Chancellor)
on Jan 08, 2003 at 11:02 UTC ( #225227=note: print w/ replies, xml ) Need Help??


in reply to Re: Two tips for developing with HTML::Template
in thread Two tips for developing with HTML::Template

Are these three independent snippets, or does your main script actually look like that?

They're independent snippets, culled from a much larger script (and template), with non-essential parts stripped away for purposes of illustrating the two techniques.

Perhaps you should have combined these techniques, pushing $@ onto @debuglog instead of printing it out.

The problem with this is twofold: first, once an exception gets caught, there's no guarantee that a template will produce output. Second, the two snippets are useful at non-overlapping phases of development. Using eval helps diagnose and repair template problems; the debug log trick helps diagnose application-level errors once templates are working. Until the former problems are handled, I don't worry about the latter ones.


Comment on Re: Re: Two tips for developing with HTML::Template
Download Code
Re^3: Two tips for developing with HTML::Template
by Aristotle (Chancellor) on Jan 11, 2003 at 19:56 UTC

    That reply doesn't make me happy. Why are you filling bits and pieces into the template here and there and everywhere, instead of accumulating the relevant data in one place during a first, application logic only phase, then passing that to the templating engine in a second, display logic only phase? Your tips themselves advertise intertwining the two, so I feel fairly secure in assuming that you are doing this throughout the rest of your code. I don't like that practice at all. Even in commandline scripts I try to keep all my prints together in one place as much as possible, not sprinkle them throughout the code.**

    ** Heredocs and (ab)using @{[ foo() ]} serves nicely as a poor man's templating engine.

    Makeshifts last the longest.

      Why are you filling bits and pieces into the template here and there and everywhere, instead of accumulating the relevant data in one place during a first, application logic only phase, then passing that to the templating engine in a second, display logic only phase?

      Fair question. In the particular case I was wresting with, a page has separate logical components. The components are handled differently by both application logic and presentation logic. I could collect all of the template parameters together from the separate objects that deal with the presentation of each component, caching the parameters until I'm ready to set all of them in one big bang, but that seems like uncessesary work.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (13)
As of 2014-10-22 07:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (114 votes), past polls