Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by bradcathey (Prior)
on Jun 16, 2004 at 12:05 UTC ( [id://367189]=note: print w/replies, xml ) Need Help??


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

kiat, I've been using HTML::Template for about 6 months now. Before that, it was all Here documents, which made it impossible for my designers to do any editing (can't expect graphic designers to learn Perl). And now, through experience and a little creativity (loops nested 3 deep which has forced me to master AoHoA....'s) I've been able to move all Perl-built HTML strings out of my Perl and into my HTML.

Do I truly have HTML separated from code (code equaling logic)? Not if you consider H::T 'code', which you often because of conventions like conditionals and loops. So, I haven't really completely separated code from HTML. My designers still have to deal with some level of 'code' when editing the HTML. Thought the use of comment tags and carriage returns between H::T and HTML, it's a little easier to read.

Because I have moved to all CSS-tableless XHTML 1.0 strict for my HTML, I can't validate my code in BBEDIT because it stumbles over all the H::T stuff. A bit frustrating (of course, it can all go in comment tags, but the doc warns of bandwidth problems, so eventually it gets stripped out.)

One thing I have improved on is using nomenclature that helps tie my MySQL tables to the loops in my HTML, so column names equal loop names.

In summary, I'm pleased with H::T and now that I'm building CMS apps, I find it indispensible. And in combo with Perl, it sure beats the ASP alternatives.

kiat, it's been interesting to read your nodes over the past 9 months. It sounds like you and I are on parallel tracks (though you are a couple of lengths ahead of me) and doing very similar work. Thanks for all your great questions—I have learned a lot in following them.

Good luck.

—Brad
"Don't ever take a fence down until you know the reason it was put up. " G. K. Chesterton
  • Comment on Re: Code and html separation - always or mostly doable?

Replies are listed 'Best First'.
Re^2: Code and html separation - always or mostly doable?
by kiat (Vicar) on Jun 16, 2004 at 12:44 UTC
    Hey, bradcathey,

    This community thrives because there are enough people with questions (good, bad or ugly) and even more people who not only have the knowledge but are willing to spend a little of their precious time to help and to share the knowledge.

    Thanks for your feedback! It's very encouraging :)

      This community thrives because there are enough people with questions (good, bad or ugly)

      yep, question means quest of knowledge.!

Re^2: Code and html separation - always or mostly doable?
by revdiablo (Prior) on Jun 16, 2004 at 17:36 UTC
    I can't validate my code in BBEDIT because it stumbles over all the H::T stuff. A bit frustrating

    HTML::Template allows you to put your TMPL_VAR, TMPL_LOOP, and other directives inside HTML comments, e.g. <!-- TMPL_VAR NAME=foo --> is the same as <TMPL_VAR NAME=foo>. Unless your HTML editing tool mangles comments, this should allow you to have your cake and eat it too.

    HTH

      True facts, revdiablo, but as I pointed out in my orig. reply, the H::T manpages state that the commented directives have a negative effect on bandwidth (but I might be misunderstanding their comment). I prolly should run some of my own tests. Thanks.

      Update: Per revdiablo's reply, below, the comment issue is one I need to look into, both for validation and readibility issues, aforementioned.

      —Brad
      "Don't ever take a fence down until you know the reason it was put up. " G. K. Chesterton

        The template directives are removed before the page is actually sent over the network, so I don't see how it would have any effect on bandwidth, one way or another. As for the comment in the POD about "dramatic savings in bandwidth," I believe they are making a joke. The size of the POD would be dramatically smaller without using comment-style directives, thus saving huge amounts of bandwidth transmitting the documentation.

        Update: for what it's worth, when I wrote my first reply, I did miss the part of your original post where you mention the comment-style directives. I apologize for that, but hopefully this post will reassure you of their use in the future.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-24 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found