Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
Welcome to the Monastery
 
PerlMonks  

Comment on

( #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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (8)
    As of 2014-04-17 06:53 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (440 votes), past polls