Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This is a technique I discovered a while ago. It will probably underwhelm a lot of people who may already have been using it for a while. However I've yet to see it explicitly discussed.

I refer to TT2 and CGI.pm's HTML generation methods as yin and yang here because their common uses represent polar opposites in the emphasis on application- vs. presentation centric design. By combinging the two, you can follow presentation centric design and get stickiness for form elements very painlessly.

So much fuss, so very little to show for it:

#!/usr/bin/perl -w use strict; use CGI; use Template # ... my $q = CGI->new; # ... $template->process("foo.tmpl.html", { query => $q, @other_variables, }) or die $Template::ERROR;
Now you can achieve sticky form elements simply by using TT2's object access capabilities to say things like
[% query.textfield("name", "J. Random Hacker", 30) %]

It is nothing earth shattering. But IMO, its usefulness is in fact because of rather than despite that.

Another use might be to implement purely presentation relevant aspects of a web application completely outside the core CGI script - after all, nothing stops you from querying parameter values as in lang = query.param('lang'); in the template. I have used this to retrofit internationalization on a CGI script without touching the Perl code at all.

Makeshifts last the longest.


In reply to Nirvana through the templating yin yang (TT2 / CGI.pm) by Aristotle

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 having an uproarious good time at the Monastery: (7)
As of 2024-03-28 17:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found