|
|
Choosing A Webhost: |
Re: extended TMPL_IF / UNLESS syntax: msg#00060lang.perl.modules.html-template
On Fri, 20 Feb 2004, Mathew Robertson wrote: > I often find myself generating template code such as: > > <TMPL_UNLESS error> > <TMPL_UNLESS print> > <TMPL_IF some_var> > .... do something... > </TMPL_IF> > </TMPL_UNLESS> > </TMPL_UNLESS> When I see stuff like that I go into my Perl code and whip up something like: <tmpl_if no_error_and_no_print> ... do something ... </tmpl_if> <tmpl_if no_error> ... do something else ... <tmpl_if error> ... do something else entirely ... </tmpl_if> That way the template stays simple and I concentrate the complex logic in the Perl code where it belongs. If possible I try to find a way to phrase each condition that doesn't involve boolean logic, which few non-programmers fully understand. > The equivalent using H::T::E would be: > > <TMPL_UNLESS EXPR="((defined error) or (defined print)) and ...."> > ... do something... > </TMPL_UNLESS> You can write that a little simpler: <TMPL_UNLESS EXPR="((error or print) and ...)"> > both syntax's are reasonably ugly... Beauty is in the eye of the beholder... > What about a syntax like: > > <TMPL_IF !error,!print,some_var> ...which is proven by the fact that I find this much uglier than either of the two alternatives! -sam ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | extended TMPL_IF / UNLESS syntax, Mathew Robertson |
|---|---|
| Next by Date: | Re: extended TMPL_IF / UNLESS syntax, Puneet Kishor |
| Previous by Thread: | extended TMPL_IF / UNLESS syntax, Mathew Robertson |
| Next by Thread: | Re: extended TMPL_IF / UNLESS syntax, Puneet Kishor |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive 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 |