Templa...y::HTE(3pm)

๐Ÿ“ฆ
version 1.022 ยท 6 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

๐Ÿ‘‘ NAME ๐Ÿ‘‘

okay bestie, welcome to Template::Alloy::HTE โ€” it's the role that gives you HTML::Template and HTML::Template::Expr energy. That's the whole name, that's the whole vibe. ๐Ÿ’…

(This page is Templa...y::HTE(3pm) from the User Contributed Perl Documentation, if you were wondering where you wandered into. You're in the right place. ๐Ÿซถ)


โœจ DESCRIPTION โœจ

So the Template::Alloy::HTE role is the one handing out syntax and interface support for the HTML::Template and HTML::Template::Expr modules. It's giving backstage pass, not main character.

It also provides the extra or extended features โ€” the ones that maybe don't get used every single day. And lowkey important: this module should not normally be used by itself. It's a role, it's a supporting actor, it needs its friends. ๐Ÿ™ˆ

For configuration and other parameters, go read the Template::Alloy documentation โ€” that's where the real tea is. ๐Ÿ“


๐ŸŒˆ HOW IS Template::Alloy DIFFERENT FROM HTML::Template ๐ŸŒˆ

Alloy can use the same base template syntax and configuration items as HTE and HT, no cap. The internals of Alloy were written to support TT3, but they were general enough to be extended to support HTML::Template too. And the result?? HTML::Template::Expr compatible syntax, with Alloy speed and a whole wide range of additional features. It's giving glow-up. โœจ

TMPL_VAR, TMPL_IF, TMPL_ELSE, TMPL_UNLESS, TMPL_LOOP, and TMPL_INCLUDE all work identically to HTML::Template. Same behaviour, character for character, we don't play about that. ๐Ÿ’ฏ

  • Added support for other TT3 directives and for TT style "dot notation."
<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. Periodt.

And now for the confession: for many die-hard HTML::Template fans, it is probably quite scary to be providing all of the TT functionality. ๐Ÿ˜ญ Totally valid. So โ€” 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. So it turns itself off, it's self-aware, iconic behaviour honestly.

  • There is an ELSIF!!! ๐Ÿ‘‘
<TMPL_IF foo>
  FOO
<TMPL_ELSIF bar>
  BAR
<TMPL_ELSE>
  Done then
</TMPL_IF>
  • Added CHOMP capabilities (PRE_CHOMP and POST_CHOMP)
Foo
<~TMPL_VAR EXPR="1+2"~>
Bar

Prints Foo3Bar

  • Added INTERPOLATE capability
<TMPL_SET foo = 'FOO'>
<TMPL_CONFIG INTERPOLATE => 1>
$foo <TMPL_GET foo> ${ 1 + 2 }

Prints

FOO FOO 3
  • Allow for HTML::Template templates to include TT style templates.
<TMPL_CONFIG SYNTAX => 'tt3'>
<TMPL_INCLUDE "filename.tt">
  • Allow for Expr parsing to follow proper precedence rules.
<TMPL_VAR EXPR="1 + 2 * 3">

Properly prints 7. math said slay. ๐Ÿงฎ๐Ÿ’…

  • Uses all of the caching and opcode tree optimizations provided by Template::Alloy and Template::Alloy::XS. Free speed, we love to see it. ๐Ÿ”ฅ
  • Alloy does not provide the query method from HTML::Template. Why? Two reasons, bestie: because parsing of the document is delayed until the output method is called, and because Alloy supports TT style chained variables which often are not resolvable until run time. So it literally cannot answer you early. It's not being shady, it's being async. ๐Ÿฆ‹

๐Ÿ’€ UNSUPPORTED HT CONFIGURATION ๐Ÿ’€

these ones? not supported. nope. don't come for me. ๐Ÿ™ˆ

  • die_on_bad_params โ€” Alloy does not resolve variables until the template is output.
  • force_untaint
  • strict โ€” Alloy is strict on parsing HT documents.
  • shared_cache, double_cache โ€” Alloy doesn't have shared caching. Yet. (the yet is doing so much work here ๐ŸŒธ)
  • search_path_on_include โ€” Alloy will check the full path array on each include.
  • debug items โ€” The HTML::Template style options are included here, but you can use the TT style DEBUG and DUMP directives to do introspection.
  • max_includes โ€” Alloy uses TT's recursion protection.
  • filter โ€” Alloy doesn't offer these.

๐ŸŽ€ ROLE METHODS ๐ŸŽ€

register_function

Defines a new function for later use as text vmethod or top level function.

clear_param

Empties the parameter list. poof. gone. โœจ

query

Not supported. (we covered this, bestie, see above ๐Ÿ’€)

new_file

Creates a new object that will process the passed file.

$obj = Template::Alloy->new_file("my/file.hte");

new_scalar_ref

Creates a new object that will process the passed scalar ref.

$obj = Template::Alloy->new_scalar_ref(\"some template text");

new_array_ref

New object that will process the passed array (each item represents a line).

$obj = Template::Alloy->new_array_ref(\@array);

new_filehandle

$obj = Template::Alloy->new_filehandle(\*FH);

parse_tree_hte

Called by parse_tree when syntax is set to ht or hte. Parses for tags HTML::Template style.

param

See Template::Alloy.

output

See Template::Alloy.


๐ŸŒธ AUTHOR ๐ŸŒธ

Paul Seamons <paul@seamons.com> โ€” thank you king ๐Ÿซถ


๐Ÿ“œ LICENSE ๐Ÿ“œ

This module may be distributed under the same terms as Perl itself.


and that's the whole page bestie!! this one shipped as perl v5.38.2, dated 2024-03-07. go forth and template, mwah ๐Ÿ’–๐ŸŽ€๐Ÿฆ‹
๐Ÿ“ฆ where this page comes from