The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::Template::Filters - HTML::Template support module, which contains some useful filters.

SYNOPSIS

  use HTML::Template::Filters qw(get_filters);

  my $filters = get_filters(
    HT_FILTER_ALLOW_TRAILING_SLASH,
    HT_FILTER_TMPL_COMMENT,
    HT_FILTER_TMPL_SET,
  );
  my $ht = new HTML::Template(
    filename => 'somefile.tmpl',
    filter => $filters,
  );

DESCRIPTION

This is a support module for HTML::Template, which contains a collection of filters that can be applied to a HTML::Template object.

Filters are applied in the order that they are specified. As such, you may need to take this into account in some situations.

FILTERS

Filters currently available (detailed below): HT_FILTER_STRIP_TMPL_NEWLINE_WHITESPACE HT_FILTER_VANGUARD_COMPATIBILITY HT_FILTER_ALLOW_TRAILING_SLASH HT_FILTER_SSI_INCLUDE_VIRTUAL HT_FILTER_STRIP_TMPL_NEWLINE HT_FILTER_GZIPPED_TEMPLATES HT_FILTER_PERCENT_VARIABLES HT_FILTER_STRIP_REDUNDANT HT_FILTER_STRIP_NEWLINE HT_FILTER_TMPL_CONSTANT HT_FILTER_TMPL_COMMENT HT_FILTER_TMPL_FIXME HT_FILTER_MAC_OS

STRIP_TMPL_NEWLINE_WHITESPACE

Strip any trailing newline and subsequence whitespace from the nextline, when using closing TMPL_xxx tags.

VANGUARD_COMPATIBILITY

Implements the H::T option of 'vanguard compatibility'. See 'PERCENT_VARIABLES'.

Note, doesn't set 'die_on_bad_params=0' (ie you may want/need to do this yourself).

ALLOW_TRAILING_SLASH

Enable HTML::Template to support the parsing of a trailing slash within template tags, as in the following:

  <TMPL_IF somevar />
    <TMPL_VAR anothervar />
  </TMPL_IF />

This may be useful for you if you use a HTML validating editor, which likes to see empty tags written as <... />.

SSI_INCLUDE_VIRTUAL

 SSI (server side includes) virtual includes

Translate SSI (server side includes) virtual includes, into H::T includes.

  <!-- #include virtual="some_include" -->

becomes

  <TMPL_INCLUDE NAME="some_include">

HT_FILTER_STRIP_TMPL_NEWLINE

Strip any trailing newlines from starting TMPL_xxx tags.

GZIPPED_TEMPLATES

This filter allows you GZip your templates, which it will uncompress them, before parsing them, as in:

  -> file stored as:     index.tmpl.gz
  -> parsed by H::T as:  index.tmpl

Note that since the templates are small files already, this capability, although quite cool, is rather stupid...!

PERCENT_VARIABLES

Allows you to use syntax like:

  ... %some_variable% ...

within your templates. You may consider this to be nicer looking than:

  ... <TMPL_VAR NAME="some_variable"> ...

STRIP_REDUNDANT

FIXME

STRIP_NEWLINE

FIXME

TMPL_CONSTANT

Allows the following syntax within templates:

  <TMPL_SET NAME="template_var" VALUE="some_value">

This will then translate all <TMPL_VAR NAME="template_var">'s into "some_value". Doesn't work for <TMPL_LOOP ..>'s as loops require the template variable to be an array (rather than a scalar). Also, dont specify ESCAPE or DEFAULT arguments to the TMPL_VAR as, they make no sense when used with TMPL_SET.

TMPL_COMMENT

Allows the TMPL_COMMENT tag so that any text between the start/end tag is stripped, as in:

  <TMPL_COMMENT>Any text between comments
  is stripped</TMPL_COMMENT>

TMPL_FIXME

Same as TMPL_COMMENT (makes for searching of FIXME's)

TMPL_JOIN

Join a TMPL_LOOP param, using the required field and seperator. Equivalent to Perl join(). The field and seperator are optional.

If using 'scalar_loops' you can easily push a simple Perl array into the template, which can then be TMPL_JOIN'ed.

Note: this filter requires the use of 'loop_context_vars'.

MAC_OS

Converts the '\r' Mac OS linefeed character to '\n' so that H::T can parse the template.

BUGS

You can send bug reports to the HTML::Template mailing-list. To join the list, visit:

  http://lists.sourceforge.net/lists/listinfo/html-template-users

CREDITS

The users of the HTML::Template mailing list contributed the idea and some patterns for the implementation of this module.

AUTHOR

Mathew Robertson <mathew@users.sf.net>

LICENSE

This module is released under the same license that HTML::Template is released under.