Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

HTML::Template regular expression usage

by sh1tn (Priest)
on Feb 18, 2008 at 12:08 UTC ( [id://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.


Replies are listed 'Best First'.
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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2025-07-12 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.