Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Two tips for developing with HTML::Template

by bart (Canon)
on Jan 08, 2003 at 09:23 UTC ( #225222=note: print w/ replies, xml ) Need Help??


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

Are these three independent snippets, or does your main script actually look like that? Because the problem I'm having with it, is that here, you appear to continue onwards with the next step, even though execution of the script should have stopped here. It doesn't make any sense to fill in template variables, if loading the template file failed. I think having one huge eval block, containing all of the code, instead of three separate ones, would make more sense.

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


Comment on Re: Two tips for developing with HTML::Template
Re: Re: Two tips for developing with HTML::Template
by dws (Chancellor) on Jan 08, 2003 at 11:02 UTC
    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.

      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://225222]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-09-18 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (101 votes), past polls