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

Re: Code and html separation - always or mostly doable?

by yosefm (Friar)
on Jun 16, 2004 at 10:44 UTC ( #367171=note: print w/replies, xml ) Need Help??

in reply to Code and html separation - always or mostly doable?

Once you understand wht is the data structure, HTML::Template is really in your favour - you can create nested loops, ifs and includes. The problem is when you want to do something like taking a simple loop and print it in two columns, and then the design of the page will reflect in your code (I did this by creating a loop of rows inside a loop of collumns). I don't know if that's considered clean enough for you, but it's batter, IMO, than printing raw HTML, since the visual design is still left to the template

A related question is printing CGI fields: put them in the template or create them with I mean:

<input type="text" value="<TMPL_VAR BlaBlaBla>" />
vs just
<TMPL_VAR BlaBlaBla>

The answer depends on the complexity of the field (a hidden field is easy to put in the template, a dynamic n-level menu isn't) and the overall level of seperation you decided on - I usually separate as much as I can. Just look at it from the design / logic point of view: "Do I have to know what widget gave me this value?" usually not. Mostly you just have to know if the value is single, multiple choice, etc. but not how it got there.

Hope this helps

perl -e'$b=unpack"b*",pack"H*","59dfce2d6b1664d3b26cd9969503";\ for(;$a<length$b;$a+=9){print+pack"b8",substr$b,$a,8;}'
My public key

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://367171]
and the sunlight beams...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2017-06-28 13:07 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (638 votes). Check out past polls.