Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

HTML::Template regular expression usage

by sh1tn (Priest)
on Feb 18, 2008 at 12:08 UTC ( #668513=perlquestion: print w/ replies, xml ) Need Help??
sh1tn has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks, I am trying to use regular expressions in .tmpl file:
<TMPL_IF my_var =~ /some string/>
Is this possible?
Thank you.


Comment on HTML::Template regular expression usage
Download Code
Re: HTML::Template regular expression usage
by wfsp (Abbot) on Feb 18, 2008 at 13:06 UTC
    Is this possible?
    No.

    From the docs

    ...it enforces an important divide - design and programming.
    The idea behind HTML::Template is that what you are trying to do is to put 'programming' in your template.

    Why can't you put that regex in your param, something like

    my $flag; if (my_var =~ /some string/){ $flag++; } my $param = { flag => $flag, };
    <TMPL_IF flag>
    imo, this restriction is a good thing. It forces you to separate your logic from your presentation, and, I think, both your code and your templates are better for it. Another benifit is that H::T is a fast, easy to use, lightweight solution for most needs.

    Perhaps consider something like Template::Toolkit if H::T is too restrictive for your needs.

    updated: fixed link

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://668513]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-08-30 07:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls