logo       

Re: FORMAT= enhancement to <TMPL_VAR> construct: msg#00018

Subject: Re: FORMAT= enhancement to <TMPL_VAR> construct
I'd generally agree (mostly) -> the formatting of data is up to the GUI designer, eg if I want the number 1000000 to contain comma's, I shouldn't need to get the Perl programmer to generate the a stringified value caontaining them.
 
Although, there would need to be alimit on this functionality, as you might end up making a scripting language just to implement this extra functionality, in a way which is extensible.  In which case, you might as well just write a Perl module to do the formatting for you.
 
regards,
Mathew
 
----- Original Message -----
From: Bob Diss
Sent: Wednesday, October 06, 2004 10:47 PM
Subject: [htmltmpl] FORMAT= enhancement to <TMPL_VAR> construct

Greetings!  In using HTML::Template I found somewhat limited by the lack of formatting ability in the template language itself.  While I recognize the need for a separation between coding and layout, I often found myself making duplicate copies of a value in different formats so that the layout people would have the version they need.  For example: sometimes they would want the value in all uppercase (for a section heading), and then again they want it in all lowercase, or sometimes they want just the first few words (to layout an article teaser).
 
To do this I implemented an idea I had seen done by a PHP translation of HTML::Template found at http://vlib.activefish.com/docs/vlibTemplate.html.  The "FORMAT=some-value" attribute to the <TMPL_VAR> construct allows the designer to alter the format of the variable.  I implemented several built-in formatters, including:
 
FORMAT=lc  --  lowercase the value
FORMAT=uc  --  uppercase the value
FORMAT=ucfirst  --  ucfirst each word in the value
FORMAT=lcucfirst  --  first lowercase the value, then ucfirst each word
FORMAT=reverse  --  reverse the value
FORMAT=length  --  output the length of the value
FORMAT=#c  -- output the first # characters of the value
FORMAT=#w  --  output the first # words of the value
FORMAT=#l  --  output the first # lines of the value
FORMAT=xxxxx  --  call the custom formatter 'xxxxx' which was declared in the 'formatters' hash when the template object was new'ed
 
Note that FORMAT does not replace ESCAPE.  Instead, they happen in sequence.  First, the value is formatted, then it is escaped.
 
Comments?  Thoughts?  Suggestions?
 
- Bob Diss
 

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe