Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
since I don't want to mirror too many cases or loops in the template that could have been done in the acutal .pl/.cgi program

I have to say that to a certain extent you are ignoring the true idea behind template integration to separate design and code. The usage of the CGI generated HTML to fill in HTML::Template variables defeats the purpose of using HTML::Template in the first place.

Imagine, the scenario where you are working in a development team where it is decided that your role is solely to develop code and the role of HTML and interface design is assigned to someone else. The best way to provide the flexibility of allowing these two roles to co-exist effectively is decided to be to make use of a templating system such as HTML::Template or Template::Toolkit. So both you and the web designer set about your respective tasks yet when it comes to integrating the form template with the CGI script, the web designer finds that their work has been invalidated through your usage of CGI-generated HTML in the template variables passed. Furthermore, think of the headache 18 months down the track when you have moved on to other things and the company wants to hire a web designer to redesign their web page ... Your usage of CGI-generated HTML in the template variables would create much heartache for the poor designer hired to edit the HTML templates.

This post is designed merely to get you thinking about the design philosophy you are taking with this usage of HTML::Template - You are rightly attempting to give yourself every opportunity to separate your design and code, yet at the same time hobbling the two together through the generation of HTML formatting by CGI rather than using the in-built templating features of HTML::Template. Admittedly in this instance, your generation of HTML by way of CGI is basic, but when I read through your code, the hairs at the back of my neck still stood on end at the thought of what it represented.

If you are finding HTML::Template too limiting with regard to template logic and layout, you may want to consider the more powerful Template::Toolkit option. But try to avoid generating your HTML from your CGI script if you are using a templating system - You are merely taking a step backwards and again hobbling code and design back together.

 

Update

I had a closer look at your code and template and it appears that there is nothing there which you are displaying as a result of code generation. I'm aware that this may be a cut-down example, but if you are not actually displaying anything in your HTML page that is a result of code or process logic, then why not just stick with a plain HTML page - The real power of templating is realised when you are seeking to incorporate code or process output into a display or page, not simply page formatting.

 

perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'


In reply to Re: HTML::Template Form Usage by rob_au
in thread HTML::Template Form Usage by bladx

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 romping around the Monastery: (6)
As of 2024-04-19 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found