Dotiac::DTL::Addon::html_template::Replace - Use Dotiac::DTL as HTML::Template
#!/usr/bin/perl -w use Dotiac::DTL::Addon::html_template::Replace; # open the html template my $template = HTML::Template->new(scalarref => \$templatedata); # fill in some parameters $template->param(HOME => $ENV{HOME}); $template->param(PATH => $ENV{PATH}); # send the obligatory Content-Type and print the template output print "Content-Type: text/html\n\n", $template->output;
Makes
Just replace
use HTML::Template;
with use Dotiac::DTL::Addon::html_template::Replace;
or
use Dotiac::DTL::Addon::html_template::Replace qw/combine/;
in the script that calls that template.
When using file names and a lot of different options to new(), Dotiac::DTL::Addon::html_template::Convert is a better choice.
new()
When set "combine" in the use statement, this module will allow combined Django and HTML::Template code:
Valid template:
{% if test or failed %}<TMPL_VAR test>{% endif %}
This is done by first converting HTML::Template code into Django template code and then parsing the whole thing again.
{% if test or failed %}{{ test }}{% endif %}
The flags will be added with a leading "+" instead of a "-".
Some options are accepted (global_vars,filter,loop_context_vars,associate,case_sensitive) the others are ignored (caching).
Sadly, the params() call without arguments and query() won't work at all prior to Dotiac::DTL 0.8, since Dotiac::DTL doesn't really care for variables until it renders.
There is one additional option to new():
Instructs Dotiac::DTL to compile the template, only works with filenames
my $t=HTML::Template->new(filename=>"foo.html",compile=>1);
Please report any bugs or feature requests to https://sourceforge.net/tracker2/?group_id=249411&atid=1126445
Dotiac::DTL, Dotiac::DTL::Addon, http://www.dotiac.com, http://www.djangoproject.com
Marc-Sebastian Lucksch
perl@marc-s.de
To install Dotiac::DTL::Addon::html_template, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dotiac::DTL::Addon::html_template
CPAN shell
perl -MCPAN -e shell install Dotiac::DTL::Addon::html_template
For more information on module installation, please visit the detailed CPAN module installation guide.