Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
As of now, I prefer inline code... most simply because I dont have still understood (nor found) practical examples of WHY templating IS better.

I did it this way too. My client gave me a hunk of ugly HTML code. It produced some very pretty pages. My client is a HTML developer. She's very very happy to edit HTML.

I thought I knew better. I rewrote the HTML into CGI functions and wrote all the functionality she was paying me for around that. When I looked at the pages they looked similar enough to me.

I thought I was being clever. I knew nothing about HTML::Template at the time. I knew next to nothing about templating. I was only doing my 3rd year of a Software Engineering degree. I knew about data separation, but I didn't think of HTML as data.

Then came the change requests. My client wanted the <TR> tag moved to here, this change, that change. Please remove the whitespace at this point as it breaks some browsers... Argh! She wouldn't touch my Perl code (which of course isn't all bad) so every single time she wanted the interface tweaked she called me. And of course I couldn't charge her because it was my fault!

Heaven forbid should she ever want the page changed in a major way. I have now ripped out the top and bottom bits and let her template them, but what about all the little bits?

Oh how I wish I'd used templates! Even simple ones that are just text files with REPLACE_ME tags in them would have been better.

When people tell you that if you don't use templates you'll regret it, they're right. If you code your HTML in to your code using HERE docs then it's a _little_ easier for the HTML person to fix on their own, but then you can run into the double update problem. I've had that too (although with PHP):

My client rings me and tells me that whenever she tries to load the page (on some pages) it seems to go into an infinite loop. I check the code, and she's right. For some reason $x-- doesn't work if $x is a float in PHP (so $x = 3.5; while($x > 0) { $x--; } won't ever stop).

So I change it to $x -= 1; and tell her it's fine. She thanks me and rings me 5 minutes later to tell me that it's broken again. What? I check and it is broken again. I fix it again and it breaks again. What's happening? Ah! She's changing the HTML embedded in my code and uploading her version over my fixed version again and again. At this point I grumble about CVS and explain to her than when she's done with her fixing, it would be nice if she'd make my change on line y.

Templating is really the only way to go. Even though it's a pain to learn and even though you think that the design is set and you won't ever, ever, ever need to redesign the webpage you're producing.

Good luck

jarich


In reply to You want to use templates... by jarich
in thread OUTPUT: inline or template_based? by CodeHound

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-29 11:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found