HTML::...terface(3pm)

πŸ’– NAME πŸ’–

HTML::Template::PerlInterface β€” bestie, this is literally the perl interface of HTML::Template::Pro. That's the whole vibe. It lives in the 3pm manual section, iykyk. πŸ’…


🌸 SYNOPSIS 🌸

okay so heads up, this help doc is only about the perl interface of HTML::Template::Pro. If you wanna know the syntax of the html template files themselves, you should go read "SYNOPSIS" in HTML::Template::SYNTAX.

First you make a template β€” and no, it's not scary, it's just a normal HTML file with a few extra tags, the simplest one being <TMPL_VAR>. slay. ✨

For example, test.tmpl:

<html>
<head><title>Test Template</title>
<body>
My Home Directory is <TMPL_VAR NAME=HOME>
<p>
My Path is set to <TMPL_VAR NAME=PATH>
</body>
</html>

See HTML::Template::SYNTAX for their syntax. πŸ“

Now create a small CGI program:

#!/usr/bin/perl -w
use HTML::Template::Pro;

# open the html template
my $template = HTML::Template::Pro->new(
      filename => 'test.tmpl',
      case_sensitive=> 1);

# 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";

# print output
$template->output(print_to=>\*STDOUT);

# this would also work.
# print $template->output();

# this would also work. It is faster,
# but (WARNING!) not compatible with original HTML::Template.
# $template->output();

If all is well in the universe, this should show something like this in your browser when you visit the CGI:

My Home Directory is /home/some/directory
My Path is set to /bin;/usr/bin

For the best performance it is recommended to use case_sensitive=>1 in new() and print_to=>\*STDOUT in output(). πŸ”₯

Also, note that (HTML::Template::Pro version 0.90+) output(), called in void context, also prints to stdout using built-in htmltmplpro C library calls β€” so that last call $template->output(); might be, in fact, the fastest way to call output(). no cap, it's giving speed. 😭

IMPORTANT NOTE: you can safely write
my $template = HTML::Template->new( ... options ...)
      or even
my $template = HTML::Template::Expr->new( ... options ...)

with HTML::Template::Pro, because in absence of original HTML::Template and HTML::Template::Expr, HTML::Template::Pro intercepts their calls. king behavior πŸ‘‘

You can also use all three modules and safely mix their calls (benchmarking may be the only reason for it, honestly). In case you want to mix calls to HTML::Template::Expr and HTML::Template::Pro, the only proper usage of their load is

use HTML::Template; use HTML::Template::Expr; use HTML::Template::Pro;

Of course, if you don't plan to mix them (which in most cases you don't), it is enough to simply write

use HTML::Template::Pro;

Simply use HTML::Template::Pro, it supports all functions of HTML::Template::Expr. periodt. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

HTML::Template::Pro is a fast C/perl+XS implementation of HTML::Template and HTML::Template::Expr. See HTML::Template::Pro for details.

It fully supports the template language of HTML::Template as described in HTML::Template::SYNTAX.

Briefly,

"This module attempts to make using HTML templates simple and natural. It extends standard HTML with a few new HTML-esque tags β€” <TMPL_VAR>, <TMPL_LOOP>, <TMPL_INCLUDE>, <TMPL_IF>, <TMPL_ELSE> and <TMPL_UNLESS>. The file written with HTML and these new tags is called a template. It is usually saved separate from your script β€” possibly even created by someone else! Using this module you fill in the values for the variables, loops and branches declared in the template. This allows you to separate design β€” the HTML β€” from the data, which you generate in the Perl script."

Here is described a perl interface of HTML::Template::Pro and HTML::Template + HTML::Template::Expr. See DISTINCTIONS for a brief summary of distinctions between HTML::Template::Pro and HTML::Template. πŸ‘€


πŸŽ€ METHODS πŸŽ€

✨ new() ✨

Call new() to create a new Template object:

my $template = HTML::Template->new( filename => 'file.tmpl',
                                    option => 'value'
                                  );

You must call new() with at least one name => value pair specifying how to access the template text. You can use "filename => 'file.tmpl'" to specify a filename to be opened as the template. Alternately you can use:

my $t = HTML::Template->new( scalarref => $ref_to_template_text,
                             option => 'value'
                           );

and

my $t = HTML::Template->new( arrayref => $ref_to_array_of_lines ,
                             option => 'value'
                           );

These initialize the template from in-memory resources. In almost every case you'll want to use the filename parameter. If you're worried about all the disk access from reading a template file, just use mod_perl and the cache option detailed below. πŸ’Ύ

You can also read the template from an already opened filehandle, either traditionally as a glob or as a FileHandle:

my $t = HTML::Template->new( filehandle => *FH, option => 'value');

The four new() calling methods can also be accessed as below, if you prefer.

my $t = HTML::Template->new_file('file.tmpl', option => 'value');

my $t = HTML::Template->new_scalar_ref($ref_to_template_text,
                                      option => 'value');

my $t = HTML::Template->new_array_ref($ref_to_array_of_lines,
                                     option => 'value');

my $t = HTML::Template->new_filehandle($fh,
                                     option => 'value');

And as a final option, for those that might prefer it, you can call new as:

my $t = HTML::Template->new(type => 'filename',
                            source => 'file.tmpl');

Which works for all three of the source types. 🫢

If the environment variable HTML_TEMPLATE_ROOT is set and your filename doesn't begin with /, then the path will be relative to the value of $HTML_TEMPLATE_ROOT. Example β€” if the environment variable HTML_TEMPLATE_ROOT is set to "/home/sam" and I call HTML::Template->new() with filename set to "sam.tmpl", the HTML::Template will try to open "/home/sam/sam.tmpl" to access the template file. You can also affect the search path for files with the "path" option to new() β€” see below for more information.

You can modify the Template object's behavior with new(). The options are available:

🌟 Error Detection Options 🌟

  • die_on_bad_params β€” if set to 0 the module will let you call $template->param(param_name => 'value') even if 'param_name' doesn't exist in the template body. Defaults to 1 in HTML::Template.

HTML::Template::Pro always use die_on_bad_params => 0. It currently can't be changed, because HTML::Template::Pro can't know whether a parameter is bad until it finishes output.

Note that it is wrapper-only option: it is not implemented in the htmltmplpro C library.

  • force_untaint β€” if set to 1 the module will not allow you to set unescaped parameters with tainted values. If set to 2 you will have to untaint all parameters, including ones with the escape attribute. This option makes sure you untaint everything so you don't accidentally introduce e.g. cross-site-scripting (CSS) vulnerabilities. Requires taint mode. Defaults to 0.

In the original HTML::Template, if the "force_untaint" option is set an error occurs if you try to set a value that is tainted in the param() call. In HTML::Template::Pro, an error occurs when output is called.

Note that the tainted value will never be printed; but, to completely suppress output, one should use call to output() that returns string, like print $tmpl->output(); Then output() will die before it returns the string to print.

Note that it is wrapper-only perl-specific option: it is not implemented in the htmltmplpro C library.

  • strict β€” if set to 0 the module will allow things that look like they might be TMPL_* tags to get by without dieing. Example:
<TMPL_HUH NAME=ZUH>

Would normally cause an error, but if you call new with strict => 0, HTML::Template will ignore it. Defaults to 1.

HTML::Template::Pro always implies strict => 0.

🌈 Caching Options 🌈

HTML::Template use many caching options such as cache, shared_cache, double_cache, blind_cache, file_cache, file_cache_dir, file_cache_dir_mode, double_file_cache to cache preparsed html templates.

Since HTML::Template::Pro parses and outputs templates at once, it silently ignores those options. πŸ™ˆ

πŸ“ Filesystem Options πŸ“

  • path β€” you can set this variable with a list of paths to search for files specified with the "filename" option to new() and for files included with the <TMPL_INCLUDE> tag. This list is only consulted when the filename is relative. The HTML_TEMPLATE_ROOT environment variable is always tried first if it exists. Also, if HTML_TEMPLATE_ROOT is set then an attempt will be made to prepend HTML_TEMPLATE_ROOT onto paths in the path array. In the case of a <TMPL_INCLUDE> file, the path to the including file is also tried before path is consulted.

Example:

my $template = HTML::Template->new( filename => 'file.tmpl',
                                    path => [ '/path/to/templates',
                                              '/alternate/path'
                                            ]
                                   );
NOTE: the paths in the path list must be expressed as UNIX paths, separated by the forward-slash character ('/').
  • search_path_on_include β€” if set to a true value the module will search from the top of the array of paths specified by the path option on every <TMPL_INCLUDE> and use the first matching template found. The normal behavior is to look only in the current directory for a template to include. Defaults to 0.

🧚 Debugging Options 🧚

  • debug β€” if set to 1 the module will write random debugging information to STDERR. Defaults to 0.
  • HTML::Template use many cache debug options such as stack_debug, cache_debug, shared_cache_debug, memory_debug. Since HTML::Template::Pro parses and outputs templates at once, it silently ignores those options. πŸ’€

✨ Miscellaneous Options ✨

  • associate β€” bestie, this one lets your object inherit parameter values from other objects πŸ’–. The only thing the other object needs is a param() method that behaves like HTML::Template's own param(). A truly iconic candidate? A CGI.pm query object. Like so:
  my $query = new CGI;
  my $template = HTML::Template->new(filename => 'template.tmpl',
                                     associate => $query);

So now $template->output() acts exactly as if this had been written out:

  $template->param('FormField', $cgi->param('FormField'));

…for every single key/value pair that $cgi->param() would hand over. And here's the tea: parameters you set directly win over associated ones. Direct > inherited, always πŸ‘‘

Wanna associate multiple objects? Pass an anonymous array to the associate option β€” they get searched for parameters in the order they appear:

  my $template = HTML::Template->new(filename => 'template.tmpl',
                                     associate => [$query, $other_obj]);
NOTE: if you've got the option case_sensitive => 0, parameter names get matched case-insensitively. So if your CGI object has two params like 'NAME' and 'Name', one of them gets chosen randomly by associate 😭. You can change that behavior by setting option case_sensitive to 1.
  • case_sensitive β€” flip this to true and HTML::Template will treat template variable names case-sensitively, no cap. Check it: the example below would only set one parameter without the case_sensitive option:
  my $template = HTML::Template->new(filename => 'template.tmpl',
                                     case_sensitive => 1);
  $template->param(
    FieldA => 'foo',
    fIELDa => 'bar',
  );

This option defaults to off, to keep compatibility with HTML::Template. That said, setting case_sensitive => 1 is highkey encouraged, because it significantly improves performance ✨.

If case_sensitive is set to 0, the perl wrapper is forced to lowercase keys in every hash it finds in the param tree, and that is sometimes an expensive operation. To dodge that, just set case_sensitive => 1. Periodt.

If you do need case conversion, there's an alternative lightweight option called tmpl_var_case, which is HTML::Template::Pro specific πŸ’….

Note that case_sensitive is a wrapper-only option β€” it is not implemented in the htmltmplpro C library.
  • tmpl_var_case β€” similar energy to case_sensitive, but this one is implemented directly in the htmltmplpro C library. Instead of converting keys in every hash of the param tree, it converts the name of the variable. Chef's kiss behavior.

Say you've got <tmpl_var name="CamelCaseName"> β€” setting tmpl_var_case = ASK_NAME_AS_IS | ASK_NAME_LOWERCASE | ASK_NAME_UPPERCASE makes HTML::Template::Pro go look in the param tree for 3 names: CamelCaseName, camelcasename, and CAMELCASENAME. Obsessed.

By default, the name is asked "as is".

  • loop_context_vars β€” set this to true (it's false by default, sadly) and boom, four loop context variables become available inside a loop: __first__, __last__, __inner__, __odd__ πŸ¦‹. They play nice with <TMPL_IF>, <TMPL_UNLESS> and <TMPL_ELSE> so you can control how a loop outputs.

On top of all that, a __counter__ var is also made available when loop context variables are turned on. Extra ✨.

Example:

   <TMPL_LOOP NAME="FOO">
      <TMPL_IF NAME="__first__">
        This only outputs on the first pass.
      </TMPL_IF>

      <TMPL_IF NAME="__odd__">
        This outputs every other pass, on the odd passes.
      </TMPL_IF>

      <TMPL_UNLESS NAME="__odd__">
        This outputs every other pass, on the even passes.
      </TMPL_UNLESS>

      <TMPL_IF NAME="__inner__">
        This outputs on passes that are neither first nor last.
      </TMPL_IF>

      This is pass number <TMPL_VAR NAME="__counter__">.

      <TMPL_IF NAME="__last__">
        This only outputs on the last pass.
      </TMPL_IF>
   </TMPL_LOOP>

One use of this feature is to provide a "separator" similar in effect to the perl function join(). Iconic. Example:

   <TMPL_LOOP FRUIT>
      <TMPL_IF __last__> and </TMPL_IF>
      <TMPL_VAR KIND><TMPL_UNLESS __last__>, <TMPL_ELSE>.</TMPL_UNLESS>
   </TMPL_LOOP>

Would output (in a browser) something like:

  Apples, Oranges, Brains, Toes, and Kiwi.

Given an appropriate param() call, of course πŸ’….

NOTE: a loop with only a single pass will get both __first__ and __last__ set to true, but not __inner__.
NOTE: in the original HTML::Template with case_sensitive = 1 and loop_context_vars, the special loop variables are available in lower-case only. In HTML::Template::Pro they are recognized regardless of case. Wild, but true.
  • no_includes β€” set this option to 1 to disallow the <TMPL_INCLUDE> tag in the template file. Use this to make opening untrusted templates slightly less dangerous πŸ™ˆ. Defaults to 0.
  • max_includes β€” set this variable to decide the maximum depth that includes can reach. Set to 10 by default. Including files to a depth greater than this value triggers an error message. Set to 0 to disable this protection entirely.
  • global_vars β€” normally variables declared outside a loop are not available inside a loop. This option makes <TMPL_VAR>s act like global variables in Perl β€” unlimited scope, main character energy πŸ‘‘. This option also affects <TMPL_IF> and <TMPL_UNLESS>.

Example:

  This is a normal variable: <TMPL_VAR NORMAL>.<P>

  <TMPL_LOOP NAME=FROOT_LOOP>
     Here it is inside the loop: <TMPL_VAR NORMAL><P>
  </TMPL_LOOP>

Normally this wouldn't work as expected, since <TMPL_VAR NORMAL>'s value outside the loop is not available inside the loop. Sad but true.

The global_vars option also lets you access the values of an enclosing loop from within an inner loop. For example, in this loop the inner loop will have access to the value of OUTER_VAR in the correct iteration:

   <TMPL_LOOP OUTER_LOOP>
      OUTER: <TMPL_VAR OUTER_VAR>
        <TMPL_LOOP INNER_LOOP>
           INNER: <TMPL_VAR INNER_VAR>
           INSIDE OUT: <TMPL_VAR OUTER_VAR>
        </TMPL_LOOP>
   </TMPL_LOOP>
NOTE: global_vars is not global_loops (which does not exist). Meaning: loops you declare at one scope are not available inside other loops even when global_vars is on. Don't get it twisted πŸ’€.
  • path_like_variable_scope β€” this option switches on a Shigeki Morimoto extension to HTML::Template::Pro that allows access to variables outside the current loop scope using path-like expressions 🧚.

Example:

{{{ <TMPL_LOOP NAME=class>
  <TMPL_LOOP NAME=person>
    <TMPL_VAR NAME="../teacher_name">  <!-- access to class.teacher_name -->
    <TMPL_VAR NAME="name">
    <TMPL_VAR NAME="/top_level_value"> <!-- access to top level value -->
    <TMPL_VAR NAME="age">
      <TMPL_LOOP NAME="../../school">  <!-- enter loop before accessing its vars -->
        <TMPL_VAR NAME="school_name">  <!-- access to [../../]school.school_name -->
      </TMPL_LOOP>
  </TMPL_LOOP> </TMPL_LOOP> }}}
  • filter β€” this one lets you specify a filter for your template files, and it's giving very much ✨power✨. A filter is a subroutine that gets called after HTML::Template reads your template file but before it starts parsing template tags.

In the most simple usage, you just assign a code reference to the filter parameter. That subroutine receives a single argument β€” a reference to a string containing the template file text. Here's an example that accepts templates with tags that look like !!!ZAP_VAR FOO!!! and transforms them into HTML::Template tags:

  my $filter = sub {
    my $text_ref = shift;
    $$text_ref =~ s/!!!ZAP_(.*?)!!!/<TMPL_$1>/g;
  };

  # open zap.tmpl using the above filter
  my $template = HTML::Template->new(filename => 'zap.tmpl',
                                     filter => $filter);

More complicated usages are possible, bestie. You can request that your filter receive the template text as an array of lines rather than as a single scalar. To do that you specify your filter using a hash-ref. In this form you specify the filter with the sub key and the desired argument format with the format key. The available formats are scalar and array. Heads up though: using the array format will incur a performance penalty, but it may be more convenient in some situations.

  my $template = HTML::Template->new(filename => 'zap.tmpl',
                                     filter => { sub => $filter,
                                                 format => 'array' });

You may also have multiple filters. This allows simple filters to be combined for more elaborate functionality πŸ”₯. To do this you specify an array of filters, and they're applied in the order they're specified.

  my $template = HTML::Template->new(filename => 'zap.tmpl',
                                     filter => [
                                          { sub => \&decompress,
                                            format => 'scalar' },
                                          { sub => \&remove_spaces,
                                            format => 'array' }
                                       ]);

The specified filters will be called for any TMPL_INCLUDEed files just as they are for the main template file. Equal treatment, as they deserve πŸ’œ.

  • default_escape β€” set this cutie to "HTML", "URL" or "JS" and HTML::Template will slap that escaping on every single variable unless a variable declares its own different escape inside the template. ✨

πŸ’– param() πŸ’–

okay so param() is genuinely the swiss army knife here, bestie β€” you can call it like five whole different ways:

  1. to get back a list of parameters in the template: (ngl this feature is distinct in HTML::Template::Pro β€” it hands you back a list of parameters that were _SET_ after new() )
   my @parameter_names = $self->param();
  1. to get back the value that's been set to a param:
   my $value = $self->param('PARAM');
  1. to set the value of a parameter:
     # For simple TMPL_VARs:
     $self->param(PARAM => 'value');

     # with a subroutine reference that gets called to get the value
     # of the scalar.  The sub will receive the template object as a
     # parameter.
     $self->param(PARAM => sub { return 'value' });

     # And TMPL_LOOPs:
     $self->param(LOOP_PARAM =>
                  [
                   { PARAM => VALUE_FOR_FIRST_PASS, ... },
                   { PARAM => VALUE_FOR_SECOND_PASS, ... }
                   ...
                  ]
                 );
  1. to set the value of a a number of parameters:
    # For simple TMPL_VARs:
    $self->param(PARAM => 'value',
                 PARAM2 => 'value'
                );

     # And with some TMPL_LOOPs:
     $self->param(PARAM => 'value',
                  PARAM2 => 'value',
                  LOOP_PARAM =>
                  [
                   { PARAM => VALUE_FOR_FIRST_PASS, ... },
                   { PARAM => VALUE_FOR_SECOND_PASS, ... }
                   ...
                  ],
                  ANOTHER_LOOP_PARAM =>
                  [
                   { PARAM => VALUE_FOR_FIRST_PASS, ... },
                   { PARAM => VALUE_FOR_SECOND_PASS, ... }
                   ...
                  ]
                 );
  1. to set the value of a a number of parameters using a hash-ref:
     $self->param(
                  {
                     PARAM => 'value',
                     PARAM2 => 'value',
                     LOOP_PARAM =>
                     [
                       { PARAM => VALUE_FOR_FIRST_PASS, ... },
                       { PARAM => VALUE_FOR_SECOND_PASS, ... }
                       ...
                     ],
                     ANOTHER_LOOP_PARAM =>
                     [
                       { PARAM => VALUE_FOR_FIRST_PASS, ... },
                       { PARAM => VALUE_FOR_SECOND_PASS, ... }
                       ...
                     ]
                   }
                  );

🧹 clear_params() 🧹

sets all the parameters to undef. Lowkey useful internally, if nowhere else! πŸ’€


πŸ“€ output() πŸ“€

output() hands you the final result of the template. In most situations you're gonna wanna print it, like:

   print $template->output();

when output gets called, every single occurrence of <TMPL_VAR NAME=name> gets swapped out for the value you assigned to "name" through param(). If a named parameter isn't set, it just gets replaced with ''. fr fr. And <TMPL_LOOPS> get evaluated once per parameter set, accumulating output on each pass. 🌸

calling output() is guaranteed not to change the state of the Template object, in case you were wondering πŸ‘€. This property is mostly important for the internal implementation of loops.

you may optionally hand it a filehandle to print to automatically as the template is generated. This may improve performance and lower memory consumption. Example:

   $template->output(print_to => *STDOUT);

the return value is undef when you use the "print_to" option. no cap.


πŸ” query() πŸ”

this method is not supported in HTML::Template::Pro. πŸ’…


πŸ¦‹ DISTINCTIONS AND INCOMPATIBILITIES πŸ¦‹

the main reason for small incompatibilities between HTML::Template and HTML::Template::Pro is the fact that HTML::Template builds a parsed tree of the template before anything else. So it has additional info that HTML::Template::Pro only obtains during output. it's giving two different brain types bestie.

in cases when HTML::Template dies β€” such as no_includes, bad syntax of template, max_includes and so on β€” HTML::Template::Pro issues a warning to STDERR and continues. 🫢

new()

these options are not supported in HTML::Template::Pro:

 vanguard_compatibility_mode.

the options die_on_bad_params and strict are ignored. HTML::Template::Pro behaves itself as HTML::Template called with die_on_bad_params => 0, strict => 0.

it currently can't be changed, because HTML::Template::Pro can't know whether a parameter is bad before it starts output. This may change in future releases. πŸ‘‘

to keep backward compatibility with HTML::Template, you should explicitly call its new() with die_on_bad_params => 0, strict => 0.

query()

this method is not supported in HTML::Template::Pro. πŸ’€

param()

param() without arguments should return a list of parameters in the template. In HTML::Template::Pro it returns a list of parameters set after new().


πŸ› BUGS πŸ›

with case_sensitive and loop_context_vars, the special loop variables should be available in lower-case only.

associate is case_sensitive inside loops.

when you're submitting bug reports, be sure to include full details, bestie!! including the VERSION of the module, a test script and a test template demonstrating the problem! πŸ₯Ί

🌈 EXPR: DEFINING NEW FUNCTIONS 🌈

to define a new function, pass a "functions" option to new:

   $t = HTML::Template::Pro->new(filename => 'foo.tmpl',
                                  functions =>
                                    { func_name => \&func_handler });

or

   $t = HTML::Template::Expr->new(filename => 'foo.tmpl',
                                  functions =>
                                    { func_name => \&func_handler });

or, you can use the "register_function" class method to register the function globally:

   HTML::Template::Pro->register_function(func_name => \&func_handler);

or

   HTML::Template::Expr->register_function(func_name => \&func_handler);

you provide a subroutine reference that'll get called during output. It receives as arguments the parameters specified in the template. for example, here's a function that checks if a directory exists:

   sub directory_exists {
     my $dir_name = shift;
     return 1 if -d $dir_name;
     return 0;
   }

if you call HTML::Template::Expr->new() with a "functions" arg:

   $t = HTML::Template::Expr->new(filename => 'foo.tmpl',
                                  functions => {
                                     directory_exists => \&directory_exists
                                  });

then you can use it in your template:

   <tmpl_if expr="directory_exists('/home/sam')">
this can be abused in ways that make my teeth hurt. 😭

✨ register_function() extended usage (HTML::Template::Pro specific) ✨

register_function() can be called in a number of ways

  1. to fetch the names of registered functions in the template:
  • if register_function() was called in a newly created object it returns a

list of functions that were set _after_ or _in_ new():

      my @registered_functions_names = $self->register_function();
  • in global context register_function() will return a list of _ALL_ available functions:
      my @all_avalible_functions_names =
   HTML::Template::Pro->register_function();
  1. to fetch the function by name:
      my $function = $self->register_function('FUNCTION_NAME');
  1. to set a new function:
       # Set function, that can be called in templates, wich are processed
       # by the current object:
       $self->register_function(foozicate => sub { ... });

       # Set global function:
       HTML::Template::Pro->register_function(barify    => sub { ... });

for details of "how to defined a function" see in "EXPR: DEFINING NEW FUNCTIONS".


πŸ”₯ EXPR MOD_PERL TIP πŸ”₯

the "register_function" class method can be called in mod_perl's startup.pl to define widely used common functions to HTML::Template::Expr. Add something like this to your startup.pl:

   use HTML::Template::Pro;

   HTML::Template::Pro->register_function(foozicate => sub { ... });
   HTML::Template::Pro->register_function(barify    => sub { ... });
   HTML::Template::Pro->register_function(baznate   => sub { ... });

πŸ™ˆ EXPR CAVEATS πŸ™ˆ

HTML::Template::Pro does not force the HTML::Template global_vars option to be set, whereas currently HTML::Template::Expr does. anyway, this also will hopefully go away in a future version of HTML::Template::Expr, so if you need global_vars in your templates then you should set it explicitly. ✨


πŸŽ€ CREDITS πŸŽ€

to Sam Tregar, sam@tregar.com

Original credits of HTML::Template:

this module was the brain child of my boss, Jesse Erlbaum ( jesse@vm.com ) at Vanguard Media ( http://vm.com ). the most original idea in this module β€” the <TMPL_LOOP> β€” was entirely his. πŸ‘‘

Fixes, Bug Reports, Optimizations and Ideas have been generously provided by:

  • Richard Chen
  • Mike Blazer
  • Adriano Nagelschmidt Rodrigues
  • Andrej Mikus
  • Ilya Obshadko
  • Kevin Puetz
  • Steve Reppucci
  • Richard Dice
  • Tom Hukins
  • Eric Zylberstejn
  • David Glasser
  • Peter Marelas
  • James William Carlson
  • Frank D. Cringle
  • Winfried Koenig
  • Matthew Wickline
  • Doug Steinwand
  • Drew Taylor
  • Tobias Brox
  • Michael Lloyd
  • Simran Gambhir
  • Chris Houser <chouser@bluweb.com>
  • Larry Moore
  • Todd Larason
  • Jody Biggs
  • T.J. Mather
  • Martin Schroth
  • Dave Wolfe
  • uchum
  • Kawai Takanori
  • Peter Guelich
  • Chris Nokleberg
  • Ralph Corderoy
  • William Ward
  • Ade Olonoh
  • Mark Stosberg
  • Lance Thomas
  • Roland Giersig
  • Jere Julian
  • Peter Leonard
  • Kenny Smith
  • Sean P. Scanlon
  • Martin Pfeffer
  • David Ferrance
  • Gyepi Sam
  • Darren Chamberlain
  • Paul Baker
  • Gabor Szabo
  • Craig Manley
  • Richard Fein
  • The Phalanx Project
  • Sven Neuhaus

Thanks! 🫢

Original credits of HTML::Template::Expr:

the following people have generously submitted bug reports, patches and ideas:

  • Peter Leonard
  • Tatsuhiko Miyagawa

Thanks! πŸ’–


🌐 WEBSITE 🌐

you can find info about HTML::Template::Pro at:

   http://html-tmpl-pro.sourceforge.net

you can find info about HTML::Template and other related modules at:

   http://html-template.sourceforge.net

πŸ‘‘ AUTHOR πŸ‘‘

Sam Tregar, sam@tregar.com (Main text)

I. Vlasenko, <viy@altlinux.org> (Pecularities of HTML::Template::Pro)

okay so before you go running off to build the cutest template engine ever, here's the boring-but-important part. It's giving "read the fine print but make it fashion" πŸŽ€

HTML::Template : A module for using HTML Templates with Perl 🌸

Copyright (C) 2000-2002 Sam Tregar (sam@tregar.com) πŸ‘‘

This module is free software β€” you can redistribute it and/or modify it under the terms of either of these two, your pick, choose your fighter:

  1. (a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version ⭐
  2. (b) the "Artistic License" which comes with this module 🎨

or, y'know, both. It's a dual-license situation, it's very main character energy πŸ’…


This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 😭 no cap, that's the whole vibe β€” see either the GNU General Public License or the Artistic License for more details, fr fr.

You should have received a copy of the Artistic License with this module, in the file ARTISTIC. If not, I'll be glad to provide one 🫢

You should have received a copy of the GNU General Public License along with this program; if not, write to:

Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA

🧚 lowkey a whole legal era. Two licenses, zero drama, one very cute template module.

and that's the whole page bestie, we ate and left no crumbs πŸ“ this was perl v5.42.3 documentation, dated 2026-08-19, for that one HTML::...terface(3pm) moment β€” go forth and template, queen πŸ‘‘βœ¨πŸ’œ

πŸ“¦ where this page comes from