HTML::Template

A

Ankur

Hi

I am new to perl. I am using HTML::Template module to display tmpl
files on the web server. But I need to use HTML::Template::Expr module
now as well, to display the values of certain expressions in the same
script.

How can I use both HTML::Template and HTML::Template::Expr module in
the same perl and template file.

I mean I need to use both the following things in the script :

<html code>

<TMPL_VAR NAME=var1>
<TMPL_VAR EXPR="10 + 12">

</html code>

Kindly help.


Ankur Jain
http://ankurjain.org
 
R

Ron Bergin

Hi

I am new to perl. I am using HTML::Template module to display tmpl
files on the web server. But I need to use HTML::Template::Expr module
now as well, to display the values of certain expressions in the same
script.

How can I use both HTML::Template and HTML::Template::Expr module in
the same perl and template file.

I mean I need to use both the following things in the script :

<html code>

<TMPL_VAR NAME=var1>
<TMPL_VAR EXPR="10 + 12">
Why would you need to want to do that? That type of expression would
be best done in the script instead of the template.
</html code>

Kindly help.

Ankur Jainhttp://ankurjain.org

This is a more appropriate example usage.

#!/usr/bin/perl

use warnings;
use strict;
use HTML::Template::Expr;

print "Content-type: text/html\n\n";

my $template = HTML::Template::Expr->new(filename => 'example.tmpl');
$template->param(var1 => 'this is var1');
$template->param(banana_count => 30);

print $template->output();

==========

<html>
<head>
<title>testing</title>
</head>

<body>
<p><tmpl_var name="var1"></p>
<p><tmpl_if expr="banana_count > (10 + 12)">I have too many bannas</
tmpl_if></p>
</body>
</html>
 
A

Ankur

Why would you need to want to do that? That type of expression would
be best done in the script instead of the template.






This is a more appropriate example usage.

#!/usr/bin/perl

use warnings;
use strict;
use HTML::Template::Expr;

print "Content-type: text/html\n\n";

my $template = HTML::Template::Expr->new(filename => 'example.tmpl');
$template->param(var1 => 'this is var1');
$template->param(banana_count => 30);

print $template->output();

==========

<html>
<head>
<title>testing</title>
</head>

<body>
<p><tmpl_var name="var1"></p>
<p><tmpl_if expr="banana_count > (10 + 12)">I have too many bannas</
tmpl_if></p>
</body>
</html>

Tbanks, it solved my problem.
 
T

Ted Zlatanov

A> I am new to perl. I am using HTML::Template module to display tmpl
A> files on the web server. But I need to use HTML::Template::Expr module
A> now as well, to display the values of certain expressions in the same
A> script.

A> How can I use both HTML::Template and HTML::Template::Expr module in
A> the same perl and template file.

My suggestion is to try the Template Toolkit (module "Template" on
CPAN). You may like it better than HTML::Template; I do after many
years of using both. It does everything HTML::Template can do AFAIK.

Ted
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,206
Messages
2,571,069
Members
47,675
Latest member
RollandKna

Latest Threads

Top