Template::Alloy::HTE(3pm) | User Contributed Perl Documentation | Template::Alloy::HTE(3pm) |
Template::Alloy::HTE - HTML::Template and HTML::Template::Expr roles.
The Template::Alloy::HTE role provides syntax and interface support for the HTML::Template and HTML::Template::Expr modules.
Provides for extra or extended features that may not be as commonly used. This module should not normally be used by itself.
See the Template::Alloy documentation for configuration and other parameters.
Alloy can use the same base template syntax and configuration items as HTE and HT. The internals of Alloy were written to support TT3, but were general enough to be extended to support HTML::Template as well. The result is HTML::Template::Expr compatible syntax, with Alloy speed and a wide range of additional features.
The TMPL_VAR, TMPL_IF, TMPL_ELSE, TMPL_UNLESS, TMPL_LOOP, and TMPL_INCLUDE all work identically to HTML::Template.
<TMPL_SET a = "bar"> <TMPL_SET b = [1 .. 25]> <TMPL_SET foo = PROCESS 'filename.tt'> <TMPL_GET foo> # similar to <TMPL_VAR NAME="foo"> <TMPL_GET b.3> <TMPL_GET my.nested.chained.variable.1> <TMPL_GET my_var | html> <TMPL_USE foo = DBI(db => ...)> <TMPL_CALL foo.connect>
Any of the TT directives can be used in HTML::Template documents.
For many die-hard HTML::Template fans, it is probably quite scary to be providing all of the TT functionality. All of the extended TT functionality can be disabled by setting the NO_TT configuration item. The NO_TT configuration is automatically set if the SYNTAX is set to "ht" and the output method is called.
<TMPL_IF foo> FOO <TMPL_ELSIF bar> BAR <TMPL_ELSE> Done then </TMPL_IF>
Foo <~TMPL_VAR EXPR="1+2"~> Bar Prints Foo3Bar
<TMPL_SET foo = 'FOO'> <TMPL_CONFIG INTERPOLATE => 1> $foo <TMPL_GET foo> ${ 1 + 2 } Prints FOO FOO 3
<TMPL_CONFIG SYNTAX => 'tt3'> <TMPL_INCLUDE "filename.tt">
<TMPL_VAR EXPR="1 + 2 * 3"> Properly prints 7.
$obj = Template::Alloy->new_file("my/file.hte");
$obj = Template::Alloy->new_scalar_ref(\"some template text");
$obj = Template::Alloy->new_array_ref(\@array);
$obj = Template::Alloy->new_filehandle(\*FH);
Paul Seamons <paul@seamons.com>
This module may be distributed under the same terms as Perl itself.
2022-10-16 | perl v5.36.0 |