Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
3790 lines (2825 sloc) 160 KB
# Changes
# Revision history for the Template Toolkit.
# Andy Wardley <>
# Version 2.27 - 13th December 2016
* Ghost fixed the regex in the uri/url filters, removing double quotes
to make it RFC3986 compliant.
* Sean Zellmer added testrules.yml to always run compile*.t sequentially
* Simon Dawson added 'empty' vmethods for scalar, list and hash
* Dennis Clark added --envvars option to tpage
* Yanick Champoux made Template::Toolkit a module
* Various warnings silenced and typos fixed.
# Version 2.26 - 17th September 2014
* Andy Wardley added outline directives. See Template::Manual::Syntax and
Template::Manual::Config for details of the OUTLINE_TAG option and new
'outline' TAG_STYLE. See t/outline.t for examples.
* Andy Wardley improved the handling of keywords when the ANYCASE option
is in use. See t/anycase.t for examples.
* Matthew Somerville fixed an issue with indentation of multiline strings
in compiled templates breaking e.g. translation.
* Chromatic fixed UTF-8 encoding in URLs in URL plugin.
* Brian Fraser added support for platforms without LC_ALL/setlocale.
* Amiri Barksdale fixed RT46691 to plug filter memory leaks
* John Lightsey fixed RT59208 to improve SET
UPDATE: This had to be reverted as it cause a subtle breakage elsewhere
# Version 2.25 - 24th July 2013
* Jon Jensen fixed the behaviour of split() which changed in Perl 5.18.0
* Jay Hannah added repository information for et. al.
* Colin Keith fixed Template::Provider's handling of directories
* Kevin Goess made the date plugin accept the ISO8601 "T" separator
* David Steinbrunner fixed various typos.
* Andreas Koenig silenced recent Pod::Simple warnings
* Slaven Rezic silenced warnings in the replace vmethod.
* Ricardo Signes made the Image plugin emit extra tags in a predictable order
* Johan Vromans added the --link option to ttree.
* Smylers added documentation for the ENCODING option.
* Andy Wardley made some minor documentation changes relating to github.
# Version 2.24 - 8th February 2012
* Added text virtual methods: upper, lower, ucfirst, lcfirst, squote,
dquote, trim, collapse, html and xml.
* Fixed bug RT#67918 - Bug in Makefile.PL command line parsing when 2 =
signs were in an argument.
* Fixed bug RT#74335 - Added documentation for some methods that were
lacking it to keep Pod::Coverage happy.
# Version 2.23 - 21st January 2012
* Fixed bug RT#47929 which caused the XS Stash to die mysteriously when
calling code that used string evaluation (e.g. DateTime).
* Fixed bug RT#68722 so that list.defined('alpha') always returns false.
* Added the TRACE_VARS option to keep track of what variables are used
in a template. It's not documented yet. See t/trace_vars.t for an
example of use.
* Applied patch from RT#48989 to avoid Template::Plugin::Procedural
from adding target class' methods AUTOLOAD and new methods multiple
times (Jens Rehsack)
* Applied patch from RT#53451 to accept negative epoch times in
* Applied patch from Marc Remy to add $Template::Directive::WHILE_MAX
option to tpage.
# Version 2.22 - 21st July 2009
* Changed pod coverage and kwalitee tests to only run when release
# Version 2.21_02 - 4th July 2009
* Added UTF8 support to the XS Stash.
* Fixed the truncate filter to handle lengths shorter than the '...'
string being appended on the end.
* Fixed a bug in the parser/grammar to make NEXT/LAST work correctly
inside nested loops.
* Fixed a bug in Template::Plugin::Filter that was causing the weakened
$self reference in a dynamic filter closure to be garbage collected
too soon. (NOTE: this has probably un-fixed a previous bug)
* Applied patch to allow list.sort to sort on multiple fields.
# Version 2.21_01 - 4th July 2009
* Removed Template::Plugin::Autoformat and t/autoform.t. They're now
available as a separate distribution.
* Fixed some Win32 test failures and XS Stash compilation problems.
# Version 2.21 - 30th June 2009
* Fixed a PRE_CHOMP bug that left \r characters lying around when
confronted with templates with DOS \r\n line endings.
* Applied patch from Bradley Baetz to fix defblock #line numbers
# Version 2.20_4 (2.21 candidate) - 21st May 2009
* Added the even(), odd() and parity() methods to Template::Iterator to
assist in making zebra tables.
* Removed a post-5.6 perlism in Template::Context that broke on 5.6.2
* Replaced a whole bunch of UNIVERSAL::isa() calls with blessed/isa
* Applied a patch from Norbert Buchmüller to prevent the #line markers
from being whitespaced away from the first column.
* Applied a patch from Denis F. Latypoff to fix uri/url filters with
utf8 text
# Version 2.20_3 (2.21 candidate) - 20th May 2009
* Fixed the XS Stash to compile properly in threaded Perls.
* Applied a patch to the XS Stash from Alexey A. Kiritchun to make the
scalar.length vmethod work correctly with utf8 strings.
# Version 2.20_2 (2.21 candidate) - 17th May 2009
* Applied a patch to Template::Test from Andrew Ford to make it skip
* Changed the ttree -v/--verbose option so be less verbose and only
report on things that have changed. To make it more verbose (like
previous versions), add a second -v/--verbose flag, e.g.
$ ttree -v -v
* Also added the --summary option to tree to print a summary of what it
did, and the --color/--colour option to make it print its verbose
messages in colour (on ANSI terminals).
* Applied a ttree patch from Lyle Brooks to allow ttree to accept a
directory name as a command line argument.
* Added the define_view() and define_views() method to Template::Context
and added the VIEWS option to pre-define views when the Template object
is created. Thanks to Timmy Chan for providing the groundwork on this.
* Retrospectively fixed the Changes for 2.20 to mention the ttree
--encoding option.
* Applied a patch from Chisel Wright, changing uses of UNIVERSAL::can()
to use blessed() and ->can().
* Fixed a memory leak in the XS Stash introduced in 2.20.
Thanks to Breno G. de Oliveira for reporting the problem and helping to
narrow it down.
# Version 2.20_1 (2.21 candidate) - 7th April 2009
* Deleted all the old HTML documentation (now available separately from, examples, libraries and
other cruft that was way out of date and badly unloved.
* Tweaked Template::Parser to work better with the ANYCASE option. It
now knows that anything following a dotop cannot be a keyword so that
you can write data.last without the 'last' bit being interpreted as the
LAST keyword. Thanks to Sean McAfee for the post that inspired it.
* Fixed a broken test for Apache::Util in the html_entity filter. Added
the use_html_entities() and use_apache_util() class methods to
Template::Filters to allow end-user selection of one or the other.
* Tweaked Template::Context to recognise Badger::Exception objects and
convert them to Template::Exception objects. This is a temporary
measure to keep things working during the transition to Badger-based
* Added the STRICT option which will cause the stash to throw an
exception on encountering an undefined value. Thanks to Ben Tilly
for the prod.
* Applied a patch to Template::Iterator from Jonathon Padfield to make
get_all() do the right thing if get_first() hasn't been called.
* Applied a patch to Template::Stash::Context from Ben Tilly to make
it easier to subclass.
* Applied a patch from Robin Berjon to add the xml filter.
# Version 2.20 - 13th August 2008
* Updated all the documentation.
* Restored the GIF images that got mangled in the switch from CVS to
* Fixed the Makefile.PL to pre-glob the tests to keep things working
smoothly in Win32.
* Applied a patch to Template::Directives from Ben Morrow to fix the
SWITCH/CASE directive when matching strings containing regex metacharacters.
* Applied a patch to Template::Parser from Koichi Taniguchi to make it
treat TAGS with case sensitivity.
* Changed html_entity_filter_factory() in Template::Filters to only look for
Apache::Utils and HTML::Entities once.
* Applied a patch to Template::Stash from Jess Robinson which allows you
to call a list method on a single object and have it automatically
upgraded to a single item list. Changed the XS Stash to do the same.
* Fixed a minor bug in the XS Stash which prevented it from updating
hash entries with empty, but defined keys. Thanks to Yitzchak
Scott-Thoennes for reporting the problem.
* Applied a patch from Alexandr Ciornii to make the XS Stash compile
cleanly under VC++ 6.0 and with Sun's C compiler.
* Fixed a minor bug in the Template::Provider code added in 2.19 that
caused errors in templates to only be reported once. Subsequent
fetches incorrectly returned 'not found' instead of repeating the
* Made Template::Provider use File::Spec->catfile instead of using '/'
and letting Perl worry about Doing The Right Thing.
* Applied patch from Lyle Brooks to add binmode to the _template_content()
method in Template::Provider.
* Applied patch from Ted Carnahan to silence UNIVERSAL::isa warnings in
* Applied patch to Template::Provider from Andrew Hamlin which works around
a bug in Strawberry Perl on Win32.
* Applied a patch from Paul "LeoNerd" Evans to make the list.slice vmethod
work properly with negative indices.
* Added the Math plugin and related files to the MANIFEST so they
actually get shipped out as part of the distribution. D'Oh!
* Added the Scalar plugin which adds the .scalar vmethod for calling
object methods and subroutines in scalar context.
* Added Template::Plugin::Assert which allows you to assert that values
are defined.
* Changed Template::Plugin::Filter to weaken the $self reference to avoid
circular references and memory leaks. Thanks to Masahiro Honma for
reporting the problem and suggesting the fix.
* Applied patch from Ronald J Kimball to make Template::Plugin::Date accept
dates with the year coming first.
* Added C<1;> to the end of a few plugin modules that were missing it.
* Changed the --accept option in ttree to match against the full file
path (relative to --src dir) rather than just the file name. This
makes it behave the same way as the --ignore option.
* Applied patch from Lyle Brooks to add binmode to the process()
call in ttree.
* Added a patch from Nigel Metheringham also to set binmode in ttree
but via a configuration option.
* Applied a patch from Éric Cholet to add the --encoding option to ttree.
# Version 2.19 - 27th April 2007
* Applied a patch to t/fileline.t from Steffen Müller which fixes the
problems running on Win32 with backslashes in paths.
* Applied a patch to the XS Stash from Randy Kobes which fixes some other
Win32 problems.
* Applied another patch to the XS Stash from Steve Peters which fixes
a problem with tied hashes under more recent version of Perl.
* Fixed a problem in the Perl Stash when using objects that have
overloaded comparison operators. Thanks to Randal Schwartz, Tatsuhiko
Miyagawa and Daisuke Maki for their contributions.
* Applied a patch from Bill Moseley to Template::Provider which adds
negative caching and moves some functionality into separate methods
to make subclassing easier. Also added the STAT_TTL configuration
* Added the url filter as a less aggressive form of the uri filter.
Whereas the uri filter now (from v2.16 onwards) encodes all the
reserved characters (@, :, /, etc.) as per RFC2396, the url filter
leaves them intact and thus behaves just like the uri filter used
# Version 2.18a - 9th February 2007
* Applied a patch from Steve Peters to the Stash.xs to allow it to
compile with bleadperl 5.9.x
# Version 2.18 - 9th February 2007
* Merged in Adam's changes in 2.16 and 2.17 back into the developer CVS
repository and added his name to the credits.
* Changed the parser grammar to accept expressions as arguments to a
subroutine, method or virtual method call. I'm embarrassed to admit
that it was a one line change that could (and should) have been made
long ago, if only I had realised just how trivial it was. Anyway,
you can now write nested expressions like this:
[% add(a+5, b < 10 ? c : d + e*5) %]
* Put the t/fileline.t test back in as this was fixed in 2.15a
* Added the Template::Toolkit documentation-only module.
# Version 2.17 - 8th Feb 2007
Another interim release from Adam Kennedy.
* Change in Makefile.PL to force an upgrade to File::HomeDir 0.64 on darwin.
This is due to problems caused by changes made to Perl on the new Intel
versions of Mac OS X.
* skip_all filelines.t on darwin
# Version 2.16 - 23rd Jan 2007
Interim release from Adam Kennedy.
* Skip fileline.t on Win32, as it has some hard-coded path seperator
assumptions. This will be fixed more comprehensively later.
* Handle spurious errors in Makefile.PL when a dev version of
ExtUtils::MakeMaker is installed.
* Don't say "nmake" on Win32 when $Config{make} is 'dmake'.
This corrects the message on Strawberry Perl.
# Version 2.15c - Not released ## DEVELOPER RELEASE ##
* Fixed a bug in Template::Parser which caused it to get confused about
block names if it encountered a syntax error inside a BLOCK. Thanks
to Bill Moseley for reporting the problem.
* Fixed a minor buglet in Template::Provider which came to light while
investigating the above problem. If a previously cached template is changed
on disk and then fails to compile, the provider now invalidates the cache
entry immediately. Without this fix, the provider would report the error
once, then reuse the cached good version of the template until $STAT_TTL
ticked over when it would try to load and compile the disk version again.
The problem was that error messages were only reported once every $STAT_TTL
second(s) and any requests for the same template in the interim time would
mysteriously work. This way errors get reported consistently and immediately
and no-one has to waste an afternoon trying to figure out where the errors
# Version 2.15b - 30th May 2006 ## DEVELOPER RELEASE ##
* Changed the uri filter to escape all reserved characters as per
URI::Escape and RFC2396. This now includes &, @, /, ;, :, =, +, ?
and $ which were previously not escaped. Thanks to
for reporting the problem.
* Also changed the uri filter to encode all wide characters as the
equivalent UTF escapes. Thanks to Jonathan Rockway for reporting
the problem.
* Fixed the redirect filter to not support relative paths. Thanks to
Paul Seamons for spotting the problem and providing a solution.
* Moved all the virtual methods out of Template::Stash and into
a new Template::VMethods module.
* Fixed the version number of Template::Stash which had rolled over
to 2.102 making it appear to predate the 2.86 stash in TT v2.14.
Thanks to Randal Schwartz for reporting the problem. Changed all
version numbers in other modules to be a hard-coded numbers instead
of grokking it automagically from the CVS revision.
* Changed the _recover() method of Template::Service to check if the
error thrown is a Template::Exception object rather than just a
reference. Thanks to David Wheeler for reporting the problem.
* Fixed the some tests in stash.t and stash-xs.t which were failing
under Perl 5.6.2 due to a slightly different error message being
generated. Thanks to Anton Berezin for reporting the problem.
* Fixed a bug in the Template::Provider _load() method to check that
$data is a hash ref before trying to mess with its innards. Thanks
to for reporting the problem.
# Version 2.15a - 29th May 2006 ## DEVELOPER RELEASE ##
* Removed the latex filter from Template::Filters and related config
variables from Template::Config
* Changed the t/fileline.t test to remove the line number from what Perl
reports as "(eval $line)". It appears to get the $line wrong on
FreeBSD, although the correct line number is reported following that
so the tests still do the right thing. Thanks to Anton Berezin for
reporting the problem.
* Changed the t/compile3.t test to do something similar.
# Version 2.15 - 26th May 2006
Chomping Options
* Added the CHOMP_GREEDY option and '~' chomping flag. Changed
CHOMP_COLLAPSE to greedily chomp all whitespace (including multiple
newlines) and replace it with a single space. Previously it only
chomped one line. Renamed the CHOMP_ALL option to CHOMP_ONE which
makes more sense. CHOMP_ALL is still provided as an alias for
CHOMP_ONE for backwards compatibility. Thanks to Paul Seamons for
doing all the hard work on this.
* Added code to the replace text virtual method to use a faster and
simpler implementation if the replacement text doesn't contain any
back references. Thanks to Josh Rosenbaum for all his efforts on
* Changed various tests for private/hidden variables (starting '_'
or '.') to use a regex defined in the $PRIVATE package variable in
Template::Stash. This can be redefined or undefined. Note that
the XS Stash only looks to see if $PRIVATE is defined or not, and
currently hard-codes the regex.
* Changed the Image plugin tag() method to call the name() method
instead of accessing the name directly, making it easier for
subclasses to provide an alternate name. Thanks to Cees Hek for
his patch.
* Change the AUTOLOAD regex in the Table plugin to be more robust.
* Added the Template::Toolkit documentation pointing people to
the right place.
* Updated the Template::Stash::XS documentation to remove the
"experimental" description and tidy things up a bit.
# Version 2.14a - 2nd February 2006 ## DEVELOPER RELEASE ##
* Activated a patch in Template::Stash from Stephen Howard which adds
code for the full set of fallbacks for dot ops called against
objects which don't implement the specific method. For example
[% hashobj.vmethod %] [% listobj.2 %] and [% listobj.vmethod %] now
all work with the Perl Template::Stash. Added code to the XS Stash
to do the same and updated tests.
* Added full support for tied hashes and tied lists in the XS Stash.
Added some further tests to make sure it's all working as expected.
* Applied path from Slaven Rezic to Template::Stash::XS to check
return code in tt_fetch_item() in a way which plays nicely with tied
* Changed Template::Stash and Template::Stash::XS to evaluate list
vmethods in lvalues.
* Changed Template::Stash to be a little more strict about what it
considers a failed method call. This allows exception thrown within
called methods to be propagated correctly rather than being ignored
as undefined method. Thanks to Dave Howorth, Tom Insam and Stig
Brautaset for reporting the problem and providing fixes.
* Removed redundant performance profiling code from
Template::Stash::XS. Must check with Doug that this is OK and he's
not still using it...
Virtual Methods
* Added the scalar.remove, scalar.substr, hash.delete, hash.items,
hash.pairs, list.import and list.hash virtual methods.
* Changed the scalar.replace method to work properly with back
references ($1, $2, etc) by incorporating ideas, code and tests from
Nik Clayton, Paul Seamon, Sergey Martynoff, Josh Rosenbaum and
* Changed list.push and list.unshift to accept multiple arguments,
thanks to Bill Moseley.
* Fixed the split scalar virtual method which wasn't accepting the
second argument (limit) correctly. Thanks to Josh Rosenbaum for
pointing out the problem.
* Documented the fact that hash.list is going to change in the future,
recommending people switch to hash.pairs.
* Added the global option to the 'match' scalar virtual method.
* Changed $element to $component in Template::Context to fix callers
bug, thanks to Andy Maas who identified the problem and found the
* Changed the sort and nsort list virtual methods to always return
references to lists, avoiding any ambiguity in return results.
* Changed the hash.defined method to do the same thing as
scalar.defined when called without arguments. Added list.defined to
do the same thing as hash.defined.
* Moved all the tests into t/vmethods/*
* Added the $Template::Plugins::PLUGIN_BASE package variable to define
the default 'Template::Plugin' value for the PLUGIN_BASE option. By
clearing this value before calling the Template new() constructor,
you can avoid having Template::Plugin added to the PLUGIN_BASE by
default. Also changed PLUGINS search to look for lower case plugin
name as well as case-specific name. Thanks yet again Josh for
addressing this issue.
* Applied a single character patch from Lubomir Host which fixes the
user attribute in Template::Plugin::File.
* Added the Math Plugin to MANIFEST.
* Changed the URL plugin to ignore parameters that are unset (e.g.
defined but zero length)
* Applied two patches to the Image plugin from Bill Moseley to escape
attributes in the tag() method and to provide the 'file' options.
Also adds proper documentation for the 'root' option.
* Added the $JOINT package variable to Template::Plugin::URL to
provide a work-around for the URL plugin which incorrectly (as
we now know) encodes '&' as '&amp;'
* Added substr() method to the String plugin, as suggested here:
* Moved all XML plugins and related tests into a separate Template-XML
* Moved DBI plugin and tests into Template-DBI distribution.
* Moved GD plugins and tests into Template-GD distribution.
* Applied a patch to the truncate() filter from "Ashley" which
adds a second argument.
* Fixed a bug in the same truncate() filter to stop it from truncating
strings that are exactly as long as the limit (change '<' to '<='),
thanks to Nicholas at
* Added "use locale" to Template::Filters to enable locale-specific
* Updated documentation to reflect the fact that the html filter also
escapes " as &quot; Thanks to Geoff Richards for reporting it.
* Moved Latex filters into Template-Latex distribution.
* Applied patch from Yuri Pimenov to prevent ttree from raising a
warning when the --depend_debug option is used.
* Applied a patch to ttree from Slaven Rezic which fixes the arguments
passed to mkpath.
* Applied a patch to ttree from Mike Schilli to prevent it from going
into an infinite loop on encountering a directory called "0"
* Fixed configuration section to not prompt "Do you want me to create
a sample .ttreerc file?" if the -h/--help options are specified,
thanks to Slaven Rezic for reporting the problem.
* added AppConfig EXPAND => EXPAND_ALL option to perl5lib,
template_plugin_base, template_compile_dir and depend_file
configuration options to allow them to contain ~ to indicate
the user's home directory, or $WHATEVER for environment variables,
as per the other path-specific options like src, lib, etc.
* Added code to Makefile.PL to detect $ENV{PERL_MM_USE_DEFAULT} to
accept all defaults. Thanks to KANE.
* Removed vStrings from Template::Document. Thanks to Dave Cross for
reporting the problem.
* Applied a patch from Barrie Slaymaker which corrects a bug in the
Template::Parser line counting when using chomp flags.
* Applied a patch from Jess Robinson to move the Template::Provider
check for file freshness into a separate method, in order to
play nicely with his Template::Provider::DBI module.
* Fixed the regex matching relative paths in Template::Provider, thanks
to Josh Rosenbaum
* Applied a patch to Template::Provider to prevent a misleading error
message, thanks to Slaven Rezic.
* Added an eval wrapper around mkpath() in Template::Provider to handle
errors more nicely.
* Numerous documentation fixes.
# Version 2.14 - 4th October 2004
* Applied patch from Harald Joerg to prevent ttree from spewing warnings
when copying files.
* Applied a patch from Paul Orrock to fix a couple of missing errors in
* Commented out line 797 of which serves no
purpose and generates a warning.
* Applied a patch from Mark Fowler to add support for Unicode to TT.
* Changed the fourth argument to process() to accept named IO layers for
binmode, e.g. process($in, $vars, $out, binmode => ':utf8');
* Added full range of command line options to tpage.
* Applied patches from Tosh Cooey, Simon Wilcox and Kenny Gatdula to fix
XML::Simple to allow direct access to XMLin() and XMLout() methods. See
* Fixed a bug in the 'callers' list maintained by a template component
which was failing to remove callers from the list after processing.
* Applied a doc patch from Dave Cash documenting caller and callers.
# Version 2.13 - 30th January 2004
* Applied patch from Dave Cash to add 'caller' and 'callers' to
'component', see
* Applied patch from Dylan William Hardison to ttree which prevents
dependencies from interfering with files that are copied. See
# Version 2.12a - 13th January 2004 ## DEVELOPER RELEASE ##
* Fixed the bug in test 25 of t/date.t, hopefully for good this time,
thanks to the efforts of Steve Peters. See:
* Added the FILE_INFO option to Template::Parser. Enabled by default,
this can be set to 0 to prevent the parser from adding file and line
info to the generated Perl file. Don't ask me why - Autrijus wanted
it (which probably means he's up to something twisted again :-). See:
# Version 2.12 - 12th January 2004
* Added the module_version() method to Template::Base to report the
version number of a module. Added some tests to t/base.t.
* Added the --template_module option to ttree, to allow the user to
specify a template processing module other than the default 'Template'
to be used. Also changed various print statements to send all
verbose output to stdout, whereas previously it was split across stdout
and stderr.
# Version 2.11b - 7th January 2004 ## DEVELOPER RELEASE ##
* Applied patch from Myk Melez to ensure the 'component' variable
remains correctly set to the current templates. See
# Version 2.11a - 6th January 2004 ## DEVELOPER RELEASE ##
* Fixed bug in t/date.t and corrected version number of
# Version 2.11 - 6th January 2004
* Bumped version number and updated documentation for release.
# Version 2.10b - 2nd December 2003 ## DEVELOPER RELEASE ##
* Changed the Template::Document process() method to pass itself
to the context visit() method when it calls it. Similarly, changed
the context visit() method to expect it. This is useful when
subclassing the context but shouldn't have any other effect.
* Modified parser to add the file name and line number of the source
template to generated Perl code. This provides useful information
when warnings and errors are generated by Perl at runtime. Added
the t/fileline.t script to test it.
# Version 2.10a - 9th October 2003 ## DEVELOPER RELEASE ##
* Applied two patches from Axel Gerstmair to fix bugs in Makefile.PL
and t/date.t. See.
* Applied patch from Jim Cromie to t/autoform.t to skip tests on all
versions of Perl from 5.8.0 onwards.
* Changed $OUTPUT in Template::Directive to be a package variable,
allowing it to be re-defined to permit a flushed output hack.
* Applied a patch from Darren to the 'item' hash vmethod to protect
against accessing private variables (prefixed '.' or '_')
* Applied a patch from Ivan Adzhubey to template/splash/frame.
* Applied a patch from Bryce Harrington to add the absolute and
relative options to ttree. Also applied a patch from Mark Anderson
to add the 'template_debug'. Removed the old debug option which was
as good as useless.
* Applied another patch from Mark to push files named on the command
line through the process_file() sub to ensure that various options
like accept checking, pemission preserving and copy processing (but
not modification time) are applied.
* Applied a variation of yet another ttree patch from Mark to add the
'suffix' option for changing the suffix of output files created.
* Applied a variation of a patch from Dylan William Hardison which
adds the 'depend' and 'depend_file' options to ttree.
# Version 2.10 - 24th July 2003
* Merged in Darren's branch to add the define_vmethod() methods to
Template::Context and Template::Stash.
* Applied patch from Axel Gerstmair for minor fixes to Makefile.PL,
t/gd.t and t/date.t.
* Added undefined() method to the Stash which get() calls if a variable
value is undefined. Currently just returns '' to implement existing
behaviour, but it provides a method hook for subclasses to redefine.
* Fixed a minor bug which prevented the Stash from being subclassable
by removing references to __PACKAGE__
# Version 2.09c - 29th April 2003 ## DEVELOPER RELEASE ##
* applied patch from Ivan Kurmanov to XPath plugin to add handling for
* modified grammar to allow 'IN' as an alternate for '=' in FOREACH
directives, thus allowing [% FOREACH item IN [ foo, bar, baz ] %]
* changed test for PROCESS option in Template::Service init from 'exists'
to 'defined' so that PROCESS set to undef Does The Right Thing.
* changed Template::process() method to accept a hash reference or list
of output options following any filename. This can now be used to
explicitly set binary mode (or not) for the output of a file. Also
changed Template::_output() method to expect a reference to text rather
than a duplicated text string (for efficiency) and also the new hash
reference of options. Also changed the redirect and stdout filters
* disabled the mandatory binmode setting on all files created under
MSWin32. See previous item for details on how binmode can now be
set explicitly, or link below for description of problem.
* applied patch from Axel Gerstmair to Makefile.PL to add TT_EXTRAS item.
# Version 2.09b - 24th April 2003 ## DEVELOPER RELEASE ##
* fixed bug introduced in 2.08e which caused some exception handling to
fail under Perl 5.6.1 and earlier.
* applied patch from Tatsuhiko Miyagawa to gd.t test to change size test
from 6500 to 6000.
* applied patch from Axel Gerstmair to the Image plugin.
# Version 2.09a - 23rd April 2003 ## DEVELOPER RELEASE ##
* added WRAPPER configuration item, documentation and tests. Also added
'wrapper' configuration item to ttree. See Template::Manual::Config
* applied patch from Axel Gerstmair to fix File::Spec and File::Temp
versions in Makefile.PL.
# Version 2.09 - 23rd April 2003
* Bumped version number for release.
# Version 2.08e - 18th March 2003 ## DEVELOPER RELEASE ##
* changed Template::Provider and Template::Context to propagate nested
exceptions (e.g. [ file => [ parse => 'blah blah' ] ]) to allow the
caller to accurately differentiate between parse errors and missing
file or other errors.
* applied a patch from Gervase Markham to add set_legend() to the
various GD::Graph modules that works with a list of arguments.
# Version 2.08d - 18th March 2003 ## DEVELOPER RELEASE ##
* Made Template::Exception DTRT with overloading (mark)
* Applied a patch from Jonas Liljegren to lower the chunking limit of
the parser regex to prevent a segfault. See
* Applied Pudge's patch for the XS Stash bug. See
# Version 2.08c - 4th November 2002 ## DEVELOPER RELEASE ##
* Applied a patch from Bradley Baetz to work around a bug in Perl when
using an overridden die(), as CGI::Carp does, for example.
* Added the Image plugin interfacing to the Image::Size module, based
on examples posted to the mailing list by Darren and Mark. See
# Version 2.08b - 1st November 2002 ## DEVELOPER RELEASE ##
* Applied two patches from Leon to fix bug in constant folding with
multiple replacements (a missing 'g' on a s///)
* Applied a patch from Tatsuhiko Miyagawa to Template::Constants to
replace 'our' perl5.6isms.
* Added the Template::Plugin::Procedural module for creating plugins that
use subroutines rather than method calls.
* Fixed a html.t test to allow numerical instead of named entities (mark)
* Added the params() method to the CGI plugin.
* Changed File::Temp and File::Basename to be loaded dynamically in
Template::Document as and when needed. Thanks to a patch from
Bradley Baetz.
* Added a preload() method to Template::Config to preload in advance
all the Template::* modules typically used. Also added call to
preload() from Template module if $ENV{MOD_PERL} is set.
* Applied a patch from Randal Schwartz to fix rowspan attribute in
templates/html/cell and templates/html/row
# Version 2.08a - 14th August 2002 ## DEVELOPER RELEASE ##
* Totally re-implemented the handling of the DEBUG parameter. Added
DEBUG_* constants to Template::Constants which can be used to enable
different debugging options and messages.
* Added skip_all($reason) to Template::Test and fixed up a whole bunch
of tests to use it. Also made other minor fixes to the tests to run
nicely (or bail politely) under Perl 5.8.0
* Applied patch from Slaven Rezic to Template::Plugin::Data which
modifies the locale loading to append various suffixes (e.g. '.UTF-8')
in the case that the unadorned locale can't be loaded.
* Bumped version number of File::Spec to 0.8 in Makefile.PL PREREQ_PM.
Previous versions didn't include splitdir(). Thanks to Slaven Rezic
for reporting the problem.
# Version 2.08 - 30th July 2002
* Applied two minor patches from Leon to remove 'use warnings' from 2
test scripts to maintain compatability with 5.005
# Version 2.07c - 22nd July 2002 ## DEVELOPER RELEASE ##
* Fixed a bug in Date plugin introduced in last version which caused
it to ignore the 'time' parameter.
* Modified INCLUDE_PATH handling in Template::Provider to accept a
reference to a subroutine or object implementing a paths() method
as an element in the list. This is then called to return a
dynamically generated path. Documented and tested.
* Changed the implementation of the NAMESPACE calling code to leave
the namespace prefix intact on the ident list which then gets
passed to the handler's ident() method. Modified the ident()
method of Template::Namespace::Constants to expect and remove it.
Constant folding now *doesn't* happen for constants that return
a reference or undefined value. These get compiled as regular
runtime variable lookups.
* Added new list virtual methods: 'unique' to cull multiple identical
items, 'merge' to merge lists together, 'splice' which acts
just like Perl's splice, and 'slice' which returns a slice of the
list. Also modified first and last virtual methods to take an
argument indicating the number of items to return from the start or
end of the list. Added the 'chunk' scalar virtual method to split a
string into chunks of a particular flushed either left or right.
(darren, mark, abw)
* Moved documentation for virtual methods into a separate manpage,
* Modifed Template::Test to allow -- name testname -- comments to
be added to tests to give them names, reported by test harness
* Merged functionality of process() and include() methods into
process() with optional third $localize flag. (darren)
* Modified the OUTPUT option to accept a reference to a list (darren)
# Version 2.07b - 7th July 2002 ## DEVELOPER RELEASE ##
Template::Namespace::Constants module, documentation and t/constants.t
test suite. This adds support for compile-time constant folding and
other custom namespace handlers.
# Version 2.07a - 5th July 2002 ## DEVELOPER RELEASE ##
* Changed the Perl and XS stashes to automatically promote a scalar
to a list and apply a list virtual method (if defined) as a last
ditch attempt.
* Changed Template::Stash::Context virtual methods to import those
of Template::Stash.
* Fixed a potential race condition when using compiled templates
by changing Template::Document::write_perl_file() to write
to a temporary file and then rename it into place, thus preventing
two separate processes attempting to write the same file at the
same time.
* Added the DEBUG and DEBUG_FORMAT options and the corresponding
DEBUG directive.
* Fixed bug introduced to Template::Provider in 2.06g which changed
handling of trailing slashes on COMPILE_DIR.
* Fixed a bug in Template::Parser to preserve any post-chomp flags
that were otherwise ignored when an entire directive is commented
out, e.g.
[%# blah
# blah
* Applied a patch from Harald Joerg so that ttree considers files
with equal mtime to be "not modified".
* Applied a patch from Keith Murphy adding the gmt flag to the Date
* Applied Makefile.PL portability patch from Chris Nandor.
* Minor documentation fixes.
# Version 2.07 - 17th April 2002
* Changed example in synopsis of Template::Plugin::XML::Style to one
based on that posted to the mailing list by Tony Bowden.
* Fixed a single/double quoting bug in docsrc which prevented [% and %]
being correctly displayed in the tables of contents in HTML docs.
# Version 2.06g - 15th April 2002 ## DEVELOPER RELEASE ##
* Fixed a bug in ttree which prevented it from passing the recurse option
onto the Template object due to a name mismatch: recurse/recursion
* Changed Template::Test to accept messages to ok(). Also added is()
as an alias for match().
* Fixed an oversight/bug in the XS stash where a missing aTHX_ around
line 546 caused compilation to fail under Win32.
* Applied a patch to Template::Provider from Alexander Schilling which
untaints paths before calling mkpath() to prevent errors under -T.
* Fixed Template::Parser so that the INTERPOLATE option now works with
files > 32K, thanks to the efforts of Stephen Adkins.
# Version 2.06f - 13th March 2002 ## DEVELOPER RELEASE ##
* Fixed a bug in both the Perl and XS Stash modules which resulted in
virtual methods being called on the base stash, e.g. [% size %]
was treated as [% stash.size %]. The only exception that we allow
through is 'import' so that we can [% import(another_hash) %]
* Fixed the compilation of the XS Stash on earlier versions of Perl
(e.g. 5.00503) and other platforms (e.g. Win32) by including the
ppport.h file.
* Fixed a warning about undefined values in Template::Plugin::Format
raised by t/format.t
* Fixed a warning in t/html.t raised when neither Apache::Util nor
HTML::Entities is installed.
# Version 2.06e - 12th March 2002 ## DEVELOPER RELEASE ##
* Fixed a minor bug in t/tiedhash.t which was trying to use the XS stash
even if it wasn't enabled. Thanks to Lyle Brooks for the patch.
* Added the 'match' virtual method for matching a string against a
regex and returning a reference to a list of (captured) (backrefs).
* Changed html filter back into a fast and simple static filter. Added
html_entity filter which uses Apache::Util or HTML::Entities to do
a complete and thorough (but slower) job. The undocumented 'entity'
option of the html filter is now removed (but may appear elsewhere).
* Added the size virtual method for scalars to prove a consistent way
of testing something.size to see if it has some value(s). For scalars
it returns 1.
* Modified the 'sort' and 'nsort' list virtual methods to allow a sort
key passed to represent a method to be called on objects in the list
as well as the key of a value to be fetched from hash references in
the list. e.g. [% books.sort('author') %] allows 'books' to contain
a list of hash refs with an 'author' key or objects with an 'author'
method. Thanks to Tony Bowden for suggesting this improvement.
* Applied a patch from Simon Wilcox to strip MS-DOS \r characters from
end of lines read by the Datafile plugin.
* Applied a patch from Ville Skyttä which fixes numerous minor bugs
in various splash templates.
* Added the 'defined' and 'exists' virtual hash methods for testing if
a value has a defined value, or exists in the hash, respectively.
* Applied a patch from Stathy Touloumis to make the XS Stash thread safe.
* Added the 'grep' virtual list method.
* Applied a patch from Mark Fowler to improve the XML XPath plugin's
handling of nested elements.
* Fixed handling of prefix support in template() and insert() methods
of Template::Content. Any prefix is stripped from the name but passed
as the second argument to the provider fetch() method. e.g.
[% INCLUDE foo:bar %] calls the foo $provider->fetch('bar', 'foo') and
[% INCLUDE %] results in a call to
$provider->fetch('//', 'http')
# Version 2.06d - 22nd January 2002 ## DEVELOPER RELEASE ##
* Applied a patch to the DBI plugin from Simon Matthews to stop it
from closing a DBH which was passed in open from an external source.
* Applied another patch from Simon to fix a bug with compiled templates
which were never being loaded due to a '<' comparison of timestamps
rather than '<='. See
* Applied a patch from Doug Steinwand which fixes a minor bug in the
XS Stash as reported by Andrey Brindeew:
* Changed URL plugin to accept multiple values for CGI parameters, e.g.
[% USE URL('/cgi-bin/foo', items=[10,20]) %] generates a URL like:
* Applied a patch from David D. Kilzer to Makefile.PL to add -I flags
to the various invocations of perl that we missed, and also to add
a clean/FILES target for WriteMakefile(). See.
* Fixed Makefile.PL to warn, not die, about mandatory modules, leaving
it to the definitions in the PREREQ_PM which the CPAN module can
understand. Thanks to Leon for waving the flag.
* Applied Leon's doc patch to the Table plugin to demonstrate
row/column transposition.
* Added ucfirst and lcfirst filters to fold first character to upper
or lower case respectively. Thanks to Paul Makepeace for the patch.
* Fixed truncate method of String plugin to not append suffix if the
string is already shorter than the required length. Thanks to
Yann Kerhervé for the patch.
# Version 2.06c - 20th December 2001 ## DEVELOPER RELEASE ##
* Changed both Perl and XS Stash modules to try to apply a SCALAR_OPS
virtual method to a blessed object as a last-ditch chance if all else
fails. Thanks to Tony Bowden for reporting the problem. See
* Added tie() method to DBI plugin which interfaces to the Tie::DBI
module, based on some plugin code sent to me courtesy of Dave
Hodgkinson. Also made various minor cleanups to DBI code and updated
documentation and tests. Incidentally, this tickled the missing
feature in the XS stash which doesn't yet support tied hashes.
* Applied a patch from Christian Schaffner which fixes a problem in
the Makefile.PL for installation via the fink package manager under
Mac OS X.
* Fixed up some of the ugliness in the docsrc tools.
# Version 2.06b - 2nd December 2001 ## DEVELOPER RELEASE ##
* Added the Template::Plugin::Filter module to make plugin filters
easier to write and rewrote the Template::Plugin::XML::Style to use
* Added the Template::Plugin::String module which provides a nice
object oriented approach to string manipulation.
* Added the '_' string concatenation operator. [% foo = bar _ baz %]
* Applied Craig's suggested fixes to the parser to correct potential
precendence problems and added tests to the test suite. See:
* Applied Leon's patch to Template::Service to delete the 'template'
entry added to the variable hash at the end of processing.
* Fixed an obscured bug/oversight in Template::Plugins which tested
generated plugin objects for truth rather than definedness to see if
the plugin returned was valid. This can cause problems if your
object has an overloaded stringification operator which gets called
(but shouldn't) and could return an untrue (but correct) value.
* Fixed t/dumper.t to only have one entry in each hash to avoid hash
ordering problems. Thanks to Randal for reporting the problem.
* Added the assert() subroutine to Template::Test.
* Added some more content to the FAQ.
# Version 2.06a - 19th November 2001 ## DEVELOPER RELEASE ##
* Added the XML::Style plugin for doing simple XML stylesheet like
transformations and t/xmlstyle.t.
* Fixed a bug in the DBI plugin where nested loops could cause the inner
query to overwrite the _STH of the outer query causing the outer loop
to end prematurely. Thanks to Dave Hodgkinson, Craig Barratt and Simon
Matthews for working on the problem and solution. For more info, see
* Applied a patch from Aleksey Nogin to Makefile.PL to call bin/gifsplash
with the '-i' option. This fixes the problem reported by Kenny Flegal:
* Applied a patch from Stas Bekman to add 'align' to template/html/row.
# Version 2.06 - 7th Nov 2001
* Fixed a bug in t/compile5.t which caused the following test warning on
Win32: "Cannot chdir to D/blah/blah/Template-Toolkit-2.05c/t/test: No
such file or directory at t\compile5.t line 73". Thanks to Chris
Winters for finding the bug and testing the fix.
# Version 2.05d - 6th Nov 2001 ## DEVELOPER RELEASE ##
* Fixed a bug in the parser which was missing a '^' anchor on the regex
matching the TAGS directive, causing it to match anywhere. Thanks to
Dominic Mitchell and Adrian Howard for reporting and fixing the problem.
* Modified Template::Parser to correctly handle "\t" and "\r" in double
quoted strings as well as "\n". Added test to t/parser.t
* Applied a patch from Stas Bekman to add 'valign' as an option to the
html/cell template.
* Applied a patch from Harald Joerg to document the 3rd $default
option to Template::Stash::set().
* Fixed a problem in the docsrc build whereby double quote strings
were causing embedded variables to be incorrectly interpolated, e.g.
[% INCLUDE xyz title="set($var, $val, $default)" %] is now
[% INCLUDE xyz title='set($var, $val, $default)' %]. Thanks to
Harald Joerg for reporting the problem.
# Version 2.05c - 22 Oct 2001 ## DEVELOPER RELEASE ##
* Applied a patch from Tony Payne which fixes a bug where templates were
being mangled under mod_perl due to a missing O_TRUNC on a sysopen().
* Fixed the mess I made of Pudge's XS Stash patch applied in 2.05b.
* Updated the INSTALL/README guides to note the PPM installation for
Win32 users.
# Version 2.05b - 21 Sep 2001 ## DEVELOPER RELEASE ##
* Applied a patch from Chris Nandor to bring the XS stash in line with
the regular Perl stash wrt accepting defined but empty keys. See
* Applied a patch to Template::Provider from Craig Barratt to fix
a bug when caching is turned off (CACHE_SIZE = 0). See
* Moved installation out of README into a separate INSTALL file and
added the HACKING document as a pointer to the internals docs.
* Added the 'uri' filter for URI escaping text.
# Version 2.05a - 12 Sep 2001 ## DEVELOPER RELEASE ##
* Applied a patch from Chris Nandor to use 'MSWin32' as a specific O/S
detection rather than /win/i which gives a false positive for 'Darwin'.
Needless to say, that's something of an insult to Darwin :-). Also
fixes Template::Provider to use File::Spec::file_name_is_absolute() to
test for absolute paths instead of the previous kludge.
* Updated Template::Manual::Internals to include information about
how to prepare patches and other useful information for potential
TT hackers.
* Added some code to the XS Stash to handle trivial access to tied
hashes. Regular set/get/default should work as expected, but at
present intermediate hashes are not auto-vivified on assignment,
e.g. [% = 10 %]
# Version 2.05 - 11 Sep 2001
* Bumped version number and updated documentation for release.
# Version 2.04f - 10 Sep 2001 ## DEVELOPER RELEASE ##
* Fixed a bug in the Date plugin which was performing one localtime() too
many when a date was passed in to the format() method. e.g. the result
from date.format('12:59::00 30/09/2001', '%H:%M') was 13:59 not 12:59.
Thanks to Thierry-Michel Barral and Matthew Tuck for reporting the
* Incorporated Doug's new version of the XS Stash. It fixes the problem
with strings not being recognized as integers (and the item = item + 1
problem). It also adds a few additional tests for this situation to
* Fixed a minor bug in Makefile.PL which looked for 'msql' or 'mysql' as
the default DBD for testing DBI but didn't select a suitable default
if the above drivers weren't available.
# Version 2.04e - 06 Sep 2001 ## DEVELOPER RELEASE ##
* Fixed bug in 'list' entry in $HASH_OPS in both Template/ and
Template/Stash/ to return '%$hash' instead of 'values %$hash'.
Thanks to Craig Barrett for reporting the problem.
* Applied a patch from Craig to and Stash/ to
accept negative integers as array indices, counting back from the
end of the list as in Perl. This brings it into line with the new
XS Stash.
* And another patch from Craig to allow $var and ${var} to be used as
keys in hashes.
* Modified Template::Plugins fetch() method to accept $factory as a
code reference. Then changed _load() to return a closure for
regular Perl modules loaded (via LOAD_PERL option) which, which
called by fetch(), removes the first argument, the $context
reference, which the non-plugin module won't be expecting. This
fixes the problem reported (and also fixed but in a slightly
different way) by Lyle Brooks, here in these messages:
* Removed the eq, ne, gt, lt, ge and ne operators added in 2.04d. Given
that they can (and did) break code that had existing variables with
those names, I decided it was best to strip them out again and think
more carefully about adding them to an official release. Hence they're
not going to be in 2.05.
* Fixed an outrageous oversight in the HTML 'rgb' template by defining
'orange' as a valid colour (I can't believe Leon hasn't already sent
me a patch for this!) Created a new custom colour scheme in the
Makefile.PL which uses it. Hacked the Makefile.PL and the generated
ttree config file to allow text colours to be specified as well as
button background colours.
# Version 2.04d - 29 Aug 2001 ## DEVELOPER RELEASE ##
* Incorporated Doug Steinwand's XS Stash. This adds the files in the
'xs' directory, t/stash-xs.t, bin/ and includes some work
on the Makefile.PL to incorporate the required prompting, etc.
* Added gt, ge, lt and le as comparison operators which map directly
to their Perl counterparts. Added tests to t/stash.t and relevant
documentation to the IF directive.
* Applied some patches from Leon and Doug to enhance the coverage of
the test suite.
* Added 'sorted' as a flag to the HTML plugin to return attributes in
sorted order. Mainly for debugging purposes, as used in t/html.t.
* Fixed to recognise "\r" as a valid escape sequence
in double quoted strings.
# Version 2.04c - 04 Aug 2001 ## DEVELOPER RELEASE ##
* Fixed t/dbi.t and t/latex*.t to not complain about "Test header seen
twice". Thanks to Leon.
# Version 2.04b - 04 Aug 2001 ## DEVELOPER RELEASE ##
* Fixed a bug in the Makefile.PL which prevented the correct targets
from being added to the generated Makefile to install additional
components, build HTML docs, etc.
* Applied a patch from Chris Nandor to fix a bug introduced by the taint
checks in 2.04 which barfed on ';' in filenames. Also changes open()
to sysopen() in Template::Document for additional security. See
* Another part of the same pudge patch adds FACTORY as a default value
to Template::Parser to allow Template::Directive factory class to
be replaced.
# Version 2.04a - 5th July 2001 ## DEVELOPER RELEASE ##
* Changed GD plugin and tests to require GD version 1.20. See
* Applied Craig's fix for the DBI plugin to correctly destroy a
statement handle to ensure that finish() gets called on it even if the
iterator doesn't complete. See:
* Further to Craig's points in the above post, I added get_all() and
get() to the DBI iterator so that you can now do this:
[% people = DBI.query(...) %]
[% person = people.get %] # first person
[% person = people.get %] # second person
[% FOREACH person = people.get_all %]
# third to nth person(s)
[% END %]
* Fixed Template::Provider which wasn't saving compiled templates to
disk when specified with an absolute path, as reported by Merlyn. See
* Updated Makefile.PL to accept various command line args including
TT_ACCEPT to automatically accept all default values and TT_QUIET to
shut the file up with all those yackety yack, yack messages.
# Version 2.04 - 29th June 2001
* Applied a patch from Craig Barratt to both the regular
Template::Stash and the alternate Template::Stash::Context which
allows array indexes into hashes and arrays (slices) in the same
manner as Perl. For example:
[% keys = [ 'foo', 'bar' ]
vals = hash.$keys # [, ]
keys = [ 2, 3, 7 ]
vals = list.$keys # [ list.2, list.3, list.7 ]
* Applied another patch from Craig to which fixes a bug
relating to text strings being interpolated in a numerical context.
* Applied yet another patch from Craig ("Man of the Patch" for v2.04 :-),
to fix a problem with NEXT not working inside switch:
FOREACH and WHILE now get a LOOP: label, and NEXT and LAST now
generate "next LOOP;" and "last LOOP;". However, the original
code allows naked "NEXT" or "LAST" (which behave like STOP). I
didn't want to change this behavior, so NEXT and LAST only get the
LOOP label inside loops (except in the top-level atomexpr FOREACH
and atomexpr WHILE cases, which should be ok).
* Does he ever sleep! :-) Another patch from Craig to improve upon
the ref->template mapping feature in Template::View. Documentation
pending. For further details, see
* Applied a patch from Mark Fowler, which fixes the problem with
search/replace virtual methods incorrectly returning with a search
pattern of '0'. e.g. [% bob = '0'; bob.replace('0', 'zero') %]
now returns 'zero' instead of ''.
* Applied a patch from Doug Steinwand to prevent the Stash from
raising undef error reporting 'Can't locate object methof "bar" via
package "Foo"' unless $DEBUG is enabled.
* Applied a patch to the DBI plugin from Rafael Kitover which calls
the DBI connect_cached() method instead of connect() to allow
connection caching in a persistent server environment (e.g. Apache
* Changed html filter to be a dynamic filter factory, allowing the
'entity' option to be set to prevent entities of the form
'&word;' being converted to '&amp;word;'
[% FILTER html(entity = 1) %]
< &amp; > # &lt; &amp; &gt;
[% END %]
* Changed Template::Stash to propogate any object errors that
are references (e.g. Template::Exception objects or otherwise)
or string that don't look like "Can't locate object method ...".
* Fixed various typos in docsrc/xml/ttdocsrc with a deft:
* Applied a patch from Leon Brocard to remove a suspect test from
t/filter.t which Chris Nandor reported as causing problems.
* Added Craig's comments on replace backreferences and TT grammar to
TODO list.
* Applied various patches from Leon: to remove redundant "print 1..0"
in various t/*.t files; to add '1;' to end of '.defaults.cfg' file;
and to fix t/vmeth.t and t/leak.t to run correctly under latest
* Applied a patch from Jonas Liljegren to fix problems with errors
being raised in -T taint mode.
* Fixed another problem identified by Jonas so that filters are no
longer cached. See:
# Version 2.03 - 15th June 2001
* Added new virtual methods 'item', 'list', 'hash' to each of scalar,
list and hash ops to Do The Right Thing to convert the original value
to what the caller wants. This is based on a patch supplied by Craig
* ...which implements a number of new features to the stash, most
notably the ability to specify the context in which you want an
object method or subroutine to be called in by appending '.list' or
'.scalar' to a dotted variable. e.g. [% cgi.param('foo').scalar %].
I haven't folded this patch into the core Stash yet (other than
adopting the virtual methods described above) but it's provided as
an alternate stash implementation, Template::Stash::Context, which
you can create and specify to your Template object via the STASH
configuration option. I'd like to a) benchmark it and b) give
people the option of trying it out (and hacking on it?) before
integrating the new features into the default stash.
* Applied a patch to add the Latex filter and GD plugin functionality,
thanks to the excellent work of Craig Barratt and Richard Tietjen.
In Craig's words:
Here is a new version of my Latex filter and GD plugin code.
(This adds a latex filter that supports PDF, PS and DVI output,
plus 16 or so plugins for the GD::* modules, allowing PNG, GIF
[Includes] Richard Tietjen's changes for the latex filter for WinXX
[which] didn't make it into the May 20th version. The new version
includes the correct changes for WinXX and also now has been
tested against TexLive and MikTeX on WinXX.
Craig's patch also included full documentation so you can read all about
it in the Manual and Module pages. In addition, the Makefile.PL now
searches for GD modules and external Latex programs and does some extra
user prompting for confirmation of Latex installation/configuration.
Not only that, but Craig also managed to roll in a couple of other
minor bug fixes and documention updates. Nice work!
* Fixed the parser to accept fully dotted up variable assignments in
argument lists, e.g. in INCLUDE, etc. You can now do this:
[% INCLUDE html/head
html.head.title = 'My Title'
Note however that the assignment to such variables is always "global",
even though INCLUDE claims to localise the stash. Remember that the
localisation does not perform a deep copy so the localised copy of
the 'html' variable might just be a copy of the reference to a previously
defined hash array. Thus, you modify the original albeit via a copy
of the reference to it. See INCLUDE section of
Template::Manual::Directives for further details.
* Added 'base' option to Template::View. This allows one view to inherit
from another "base class" view. If a template isn't defined in a
derived view then it automatically asks its base view for it, and so
on up the inheritance tree.
[% VIEW myview.default
prefix = 'view/default/';
[% VIEW myview.fancy
base = myview.default
prefix = 'view/fancy/';
In this example, [% myview.fancy.header %] will be resolved as
[% INCLUDE view/fancy/header %] or [% INCLUDE view/default/header %]
if 'view/fancy/header' doesn't exist. Variables are also inherited.
* Added the 'sealed' and 'silent' parameters to VIEW to allow view to be
optionally unsealed (allow external variable updates/creation) and
to silence warnings about attempts to update sealed variables,
respectively. See the Template::Manual::Views page for more info on
this and previosu item.
* Added the HTML plugin for generating (very basic) HTML elements.
See the Template::Plugin::HTML documentation.
* Added the present() and content() methods to XML::DOM::Node in the
XML::DOM plugin to make them work harmoniously with VIEWs. See the
Template::Plugin::XML::DOM documentation for further details.
* Did the same for Template::Plugin::XML::XPath, adding present($view)
and content($view) methods to XML::XPath::Node::Element and a
present($view) method to XML::XPath::Node::Text. See the
Template::Plugin::XML::DOM documentation for more details.
* Added the calc() method to the Date plugin to return an interface to
the Date::Calc module. e.g.
[% USE Date; calc = Date.calc %]
[% calc.Monday_of_Week(22, 2001).join('/') %]
* Moved Template::Tutorial to Template::Tutorial::Web and added the
tutorial kindly donated by Dave Cross on generating and using data
files with TT as Template::Tutorial::Datafile. Template::Tutorial
is now an index to the tutorials.
* Changed the bin/tt2inst script to no longer use the 'no_chdir' option
of the File::Find module which isn't supported in earlier version such
as distributed with pre-5.6.0 Perl. Thanks to a patch from Vivek
Khera <>. Changed Makefile.PL to accept File::Spec
version 0.6 or later.
* Fixed a bug in the FOREACH directive which would barf with the error
"undef error - loop is undefined" when DEBUG was enabled.
* Applied a patch from Eric Cholet to fix a bug in META data items not
correctly escaping ' and \ characters.
* Applied another patch from Eric to fix "Use of uninitialised value"
warning when using a subclassed parser.
* Applied a patch to ttree from Leon Brocard print full path for ignored
* Fixed typo in the ttree help page which incorrectly listed debug
mode as '-d' (now '-dbg' as well as '--debug')
* Fixed (hopefully once and for all!) the problem with choming the
final newline in a template. The last newline is now chomped just
like any other, depending on the POST_CHOMP flag and/or trailing '-'
in the directive. e.g.
[% FILTER latex('ps') %]
[% END -%]
If you explicitly want a newline then make sure one is added to the
end of the template and don't enable POST_CHOMP or add a trailing '+'
in the directive, e.g.
[% INCLUDE footer +%]
* Made a number of fixes to the HTML generated by the Splash! and HTML
libraries to make it conformant with HTML 3.2 specificiation. Added
DOCTYPE to html/header, ALT tags, ... added html/head, html/body and
html/html to do more thorough job using nested variables. Also added
html/config to load HTML plugin. Full conformance is still an issue,
but we're working on it...
# Version 2.02 - 6th April 2001
* Updated various components of the Splash! library, cleaned up some
ugliness (a little) and revised the examples. Documentation in
Template::Library::Splash is now hopelessly out of date but examples
are more comprehensive. Makefile.PL now prompts user to select a
colour scheme for creating the documentation and examples.
* Fixed problems with Splash! images displaying the "wrong" colour on
certain systems. It appears to be the case that this was automatic
gamma correction at work, an otherwise very cool feature of PNG
files. Alas it broke things here so we've switched to GIF files.
Also made an improvement to the way of generating and using the
images. By using simple transparency and doing away with the
anti-aliasing it's possible to support any foreground colour for a
set of images in a background colour. One set of black images are
now distributed with TT. These are blown into many colours during
installation, implemented by the bin/gifsplash script and defined
as the 'tt2_splash' Makefile target, run automatically as part of
'make install'.
* Changed redirect filter factory and the underlying Template::_output
method to accept a 'binmode' flag. The bin/gifsplash script sets
this flag to ensure that the GIFs generated for Splash! are valid on
Win32 platforms (it's a good job SAM knows what binmode is for... :-)
* Applied a patch from Leon Brocard to add 'recurse' and 'verbose'
options to the ttree.cfg files generated by Makefile.PL. Their
absence was preventing the docs and examples from being built
(unless, like the stupid author, you already had a default
~/.ttreerc which included these flags :-).
* Fixed Makefile.PL to check for File::Spec 0.82, thanks to the efforts
of Doug Steinwand and Leon who found and fixed the problem with
'splitdir' otherwise not being available. Later changed requirement
from 0.82 to 0.80 because this is the version currently distributed
with ActivePerl 5.6.0 and it appears to work just fine (saves those
poor Win32 users from having to install any more modules than
absolutely necessary)
* Removed test for platform specific error messages from t/xpath.t
Removed warning from README that this test would fail. Thanks
again to Leon for the patch and to <> (no name
given) for reporting the problem.
* Applied another patch from Leon to fix to avoid
"Use of uninitialized value..." warnings.
* Applied yet more patches from Leon to add "use Template::Plugin" or
something similar to the File, Directory and View plugins. 'use
base' doesn't work as advertised (e.g. in ensuring the module is
loaded) in older versions of Perl.
* Fixed t/leak.t to only run one particular test if Perl version is
5.6.0 or greater. Test fails on earlier versions due to destructors
being called in a different order.
* Updated Makefile.PL to supply a more typical default installation
directory for Win32 systems - C:/Program File/Template Toolkit 2/.
This brought to light numerous bugs (following) which were fixed
with the invaluable help of Simon Matthews and Theakston's Black
Sheep Ale... :-)
* Pathnames generated in the Makefile.PL for the Makefile are now all
"double quoted" to protect embedded whitespace, e.g. when building
docs: ttree -f "C:/Program Files/...")
* Patched Template/ in several places to strip out any
extra ':' characters put in the wrong place of a path. For example,
when writing compiled template "C:/foo" to disk with a COMPILE_DIR
of "C:/bar", the resulting file is now "C:/bar/C/foo" instead of
the erroneous "C:/bar/C:/foo".
* On Win32 systems, provider prefixes must be more than 1 character in
length. This is a compromise for cases where you might want to do
something like: [% INCLUDE C:/foo/bar %]. Remains unchanged on
other platforms.
* On Win32 systems the DELIMITER now defaults to a slight variation of
':' if not otherwise set. It now uses /:(?!\/)/ to split on ':'
where not followed by '/'. This makes things like INCLUDE_PATH =>
'C:/here:C:/there' work properly, although setting a more suitable
DELIMITER for Win32 systems (e.g. ';') is still recommended (we tried
automatically setting it to ';' on Win32, but that caused more problems
than it was worth).
* Changed Template::Provider to consider a file starting (\w:)?/ as an
ABSOLUTE path when running on Win32 (e.g. C:/foo). On other
platforms, it remains unchanged, looking only for a leading '/'.
Also changed ttree to do the same, so that 'ttree -f C:/test.cfg'
is treated as an absolute path and it doesn't try and prefix it
with the ttree configuration file directory. Note that ttree
does this regardless of OS.
* Fixed stringification problem identified by SAM. Objects that have
auto-stringification sometimes didn't get properly stringified at the
right time. e.g. [% a = "$an_obj" %].
* Fixed File and Directory plugins to gracefully ignore Perl dying with
"getpwuid() not supported on this platform" errors on Win32. The
'uid' and 'user' attributes of File and Directory plugin objects
are left undefined.
* Then, hacked t/file.t and t/directry.t test to not be run under
Win32. There are a couple of outstanding minor problems with these
test scripts caused by differences in '/' and '\' as path
separators. Need to fix these at some point.
* Makefile.PL now saves configuration options in '.defaults.cfg'
file, using these values as defaults when run again.
* Removed duplicated $VERSION from DBI and XML::DOM plugins, thanks
to Jonathan Leffler.
* Updated documentation to reflect new changes.
# Version 2.01 - 30th March 2001
* Added the various template libraries in the 'templates' directory.
The 'html' library implements some generally useful HTML elements.
The 'pod/html' libraray contains some templates for converting POD to
HTML, used in building the TT2 HTML documentation, for example. The
'ps' library contains templates defining a few useful marks and other
procedures for generating PostScript pages. The 'splash' directory
contains templates for the "Splash!" library which implements a
widget set for building stylish HTML user interfaces.
* Added a host of example pages in the 'examples' directory which
demonstrate use of the above libraries.
* Added an 'images' directory to contain the small images used to build
up the Splash! interface components.
* Added the 'docs' directory containing templates and library elements
for building the TT2 documentation as HTML pages.
* Updated Makefile.PL to now offer to install optional libraries,
images, build HTML docs, examples, etc. Adds 'tt2_install',
'tt2_html_docs' and 'tt2_examples' as Makefile targets if requested.
These then get run as part of "make install".
* Totally re-organised the documentation, splitting the long user manual
into separate Template::Manual::* pages, adding the Template::FAQ,
Template::Internals, and various other changes. All POD and HTML
documentation is built from the same sources in the form of another
set of templates, POD files, XML files, scripts, etc., distributed
separately as the 'docsrc' bundle, and available from the web site.
The POD documentation now gets glued onto the end of the .pm
modules and only creates separate .pod files for those manual pages
that don't have equivalent modules (e.g. Template::FAQ, etc.)
NOTE: this might mean that existing .pod files from earlier versions
of TT might mask documentation in newer .pm files...
* Added the Template::View module, the VIEW directive and the View
plugin which can be used collectively to create dynamic views. This
is a very powerful tool which fulfills a number of requirements and
makes possible a number of things that have previously been messy,
difficult or not possible. Views are primarily collections of
templates. You can define BLOCKs within a view and they remain
local to it, but can be called from outside the view. This is still
very experimental. Things are likely to change. See
Template::Views for (incomplete) documentation and take a look at
t/view.t for examples.
[% VIEW fancy_html
prefix = 'splash/' # template prefix/suffix
suffix = '.tt2'
bgcol = '#ffffff' # and any other variables you
style = 'Fancy HTML' # care to define as view metadata,
items = [ foo, bar.baz ] # including complex data and
foo = bar ? baz : x.y.z # expressions
[% BLOCK header %] # define "private" view blocks
Title: [% title %]
[% END %]
[% END %] # end of VIEW definition
[% v = fancy_html %] # view is a regular object ref, re-
[% mycode(v) %] # assign it, pass it around, etc.
[% v.title %] # access view metadata
[% v.header(title = 'Foo!') %] # view "methods" process blocks or
[% v.footer %] # templates with prefix/suffix added
# => [% INCLUDE splash/footer.tt2 %]
* Added the facility to specify multiple templates within a PROCESS,
INCLUDE, INSERT or WRAPPER directive. For all but WRAPPER, the
templates are processed in the order specified.
[% PROCESS config + header + menu %]
[% INCLUDE section/break + html/titlebar
title='A New Section'
[% WRAPPER edge + box + titlebar %]
[% END %]
Multiple WRAPPER templates get processed in reverse order to create
the correct nesting effect. In the example above, the enclosed block
is processed and passed to 'titlebar' which wraps it and passes the
output to 'header' which wraps it and passes the output to 'box', which
wraps it and passes the output to 'edge' which wraps it and returns the
output. Thus the specification order is outermost to innermost, but
they are actually processed from the inside out.
* Templates specified to INCLUDE, PROCESS, WRAPPER and INSERT can now
be given a prefix (delimited by ':', as in "file:blahblah.txt" or
"", for example) which maps them to a
particular template provider or providers. A PREFIX_MAP
configuration option can be specified as a hash array mapping prefix
names to a reference to a list of providers. For convenience, you
can also specify the argument as a string of integers, delimited by
any non-numerical sequence, to indicate indices into the LOAD_TEMPLATES
provider list. e.g.
my $template = Template->new({
LOAD_TEMPLATES => [ $foo, $bar, $baz, $wiz ],
src => '0, 2', # $foo and $baz
lib => '1, 2', # $bar and $baz
all => '0, 1, 2', # $foo, $bar and $baz
Thus [% INCLUDE src:hello.tt2 %] indicates the 'hello.tt2' template
to be provided by $foo or $baz, [% INCLUDE lib:hello.tt2 %] is mapped
to $bar and $baz, [% INCLUDE all:hello.tt2 %] can be provided by
$foo, $bar or $baz, and the default [% INCLUDE hello.tt2 %] is
mapped to the entire LOAD_TEMPLATES list: $foo, $bar, $baz and $wiz.
This is initially useful for things like ttree which would like a way
to differentiate between templates in one place and templates in
another. It can also be used, of course, to provider special providers
for certain file type, as in
* Fixed the parser to accept expressions on the right hand side of
parameter definitions for INCLUDE, etc. e.g.
[% INCLUDE header
title = my_title or your_title or default_title
bgcol = (style == 'dark' ? '#000000' : '#ffffff')
* Added the PLUGIN_FACTORY configuration option to Template::Plugins
to allow class names or object prototypes to be specified for plugins.
No module loading is attempted, unlike the existing PLUGINS which
assumes entries are module names which it tries to load. This may
change in a future release (ideally by integration with PLUGINS) so
it remains undocumented for now.
package My::Plugin;
package main;
my $tt = Template->new({
plugin1 => 'My::Plugin', # class name
plugin2 => My::Plugin->new(), # prototype obj
* Added the File and Directory plugins which blossomed from the
Directory plugin written by Michael Stevens and posted to the
mailing list. These give you access to files and directories on
your filesystem and also allow you to create representations of
abstract files/dirs.
WARNING: recognise that this gives the author of any templates you
run access to information about your filesystem. We assume that the
author of your templates is you or someone you trust to have access
to that kind of information. If you're running "untrusted"
templates (we assume you know what you're doing) then you'll very
probably want to disable these plugins. Alas there is no easy way
to disable plugins at the moment other than deleting them or writing
null or error throwing plugins to mask them. Making this easier is
* Added the Pod plugin which uses the Pod::POM module to parse a Pod
file or text string and build an object model. You can then walk
it and present it in different ways using templates. Great for
building HTML documentation from Pod and unsurprisingly used to
build the new TT2 docs.
* Applied a patch from Chris Nandor to add a new feature to the
PRE_CHOMP and POST_CHOMP options. When set to 1, they continue to
act as before. When set to 2, all whitespace is collapsed into a
defined in Template::Constants and can be imported as the :chomp
tagset, for those who want them.
* Applied a patch from Doug Steinwand to fix a problem in
Template::Provider which would server stale templates if the
modification time of the files went backwards. In addition, it now
uses the $Template::Provider::STAT_TTL (time to live) variable
(default: 1) to determine how often to stat the files to check for
changes. TT2 now supports time running backwards! :-)
* Applied a patch from Vivek Khera which fixes a memory leak in the
MACRO directive, prevalent when using TT under mod_perl. Also added
t/leak.t to test that memory is properly freed and circular references
broken by the delocalisation of the stash. All seems to work as expected
including plugins that contain context references, MACRO definitions,
and so on (but note that this is the test suite run from the command
line, and doesn't explicitly test under mod_perl...)
* Applied a patch from Axel Gerstmair to fix a bug in PERL blocks
and filters which caused references to the context and stash to be
kept in global package variables. This meant they stayed alive for
far too long. Added a couple of tests to t/leak.t to check this now
works OK.
* Fixed a bug in the parser triggered by [% CATCH DEFAULT %]. Thanks
to Vivek Khera for reporting the problem. This also fixes a problem
reported by Thierry-Michel Barral which was causing bare 'CATCH'
blocks to not catch errors and instead pollute STDERR.
* Fixed another bug in the parser preventing double quoted META attributes
from containing single quotes, e.g. [% META title="C'est un test" %].
Thanks to Philippe Bruhat for reporting the problem.
* Added the 'indent' filter to indent a block by prefixing each line with
a specified string, or a number of spaces when the argument is numerical.
* Added the 'trim' filter to remove leading/trailing whitespace and
'collapse' filter to additionally collapse multiple whitespace characters
to a single space.
* Added escapes for ' (&apos;) and " (&quot;) to the html filter, thanks
to Lyle Brooks and Vivek Khera. Then, having done that, I removed
the &apos; escape because my browser didn't recognise &apos; as a
valid entity. What's going on here? Need to check the HTML spec...
* Added tag style 'star' of the form [* ... *]
* Changed the Template::Stash get() and set() methods to accept a
compound variables as a single parameter and automatically convert
it to an array. Note that it doesn't correctly handle arguments
to dotted elements (e.g. foo(10).bar(20), but does mean that you can
now write $stash->get('') instead of the more laborious
$stash->get(['foo', 0, 'bar', 0, 'baz', 0]).
* Fixed a bug in Template::Stash which was raising an error when an
element on the left hand side of a '.' evaluated to a defined, but
empty value.
* Fixed an obscure bug in Template::Stash which occurred when calling
a scalar method on a value which contained a valid and visible object
package name. e.g. [% name = 'Foo::Bar'; name.baz() %] called
* Fixed a bug in the Template::Stash 'replace' virtual method which
returned the original string when the replace string was specified
empty. [% var = 'foo99'; var.replace('foo', '') %] now correctly
returns '99' instead of the original string 'foo99'. Thanks to
Tryggve Johannesson and Jeremy Wadsack for reporting the problem.
* Added magical handling of the 'import' variable to stash clone() and
update methods. This implements the V1 functionality whereby you can
write [% INCLUDE foo import=myhash %]. Note that 'import' is lower case,
(V1 was upper case IMPORT) as in V2 it is in keeping with the virtual
hash method (e.g. same as myhash.import(another.hash)). Thanks to
Brian Cooper for raising the issue.
* Yet another change to Template::Stash. Objects which are blessed
arrays will now honour virtual array methods if the object doesn't
otherwise implement a particular method. For example, you can now
write [% USE Datafile(...) %] and then [% Datafile.size %]. The
'.size' now works as virtual method on the blessed ARRAY which
consitutes the Datafile object. Thanks to Keith Murphy for
identifying the problem.
* Fixed another obscure bug, this time in Template::Parser which wasn't
chomping the final newline in the input string. Thanks to Paul
Makepeace for reporting the problem.
* Finally identified the cause of an error occasionally being reported
by Template::Service when is thrown a non-reference exception. It
appears to be a problem interacting with CGI::Carp. For now, it's
fixed and tolerated in Template::Service (but could possibly do with
a better long term solution?). Thanks to Jo Walsh, Trond Michelson,
and I'm sure several others who reported this and helped to track
the problem down (and also fixing the confess() bug I introduced
when I added the tracer code. D'Oh!)
* Removed some old "delegate-to-another-object" code from Template::Plugin,
including a nasty AUTOLOAD method which prevented derived objects from
acting as transparent hashes. If delegative functionality is required
then it should be implemented as Template::Plugin::Delegate (and may
well be in the fullness of time).
* Fixed a whole bunch of typos and spellos thanks to patches from Leon,
Paul Sharpe and Robert McArthur.
# Version 2.00 1st December 2000
* Added the repeat(n), search(pattern) and replace(search, replace)
virtual methods for scalars, and fixed a warning in the split()
method raised when an attempt was made to split an undefined value.
* Changed the THROW directive to accept multiple parameters which
become named items of the '' item, thanks to a suggestion
from Piers Cawley. Positional arguments can be addressed as
[% %] or as a list as [% %]. Named
parameters can be accessed as [% %].
[% TRY %]
[% THROW foo 'one' 2 three=3.14 %],
[% CATCH %]
[% error.type %] # foo
[% %] # one
[% %] # 2
[% %] # 3.14
[% END %]
* Moved the definition of Template::TieString from Template::Directive
into Template::Config (for now) to ensure that its definition is
visible even if the Template::Parser, and through it, the
Template::Directive module, haven't been loaded. This fixes the
bug causing the error "Can't locate object method "TIEHANDLE"
via package Template::String..." raised when using EVAL_PERL with
compiled templates only. In this case, the parser wasn't getting
loaded (because it had no templates to parse, them all being pre-
compiled) and the Template::TieString defintion wasn't visible to
the EVAL_PERL blocks that require it. Added a test to t/compile3.t.
Thanks to Igor Vylusko for reporting the problem.
* Changed the Template::Directive Perl generator for EVAL_PERL blocks
to generate code to first test the EVAL_PERL option in the runtime
context and throw a 'perl error - EVAL_PERL not set' exception if
unset. Thus the behaviour for EVAL_PERL when using compiled templates
is now: if the EVAL_PERL option isn't set in the _compiling_ context,
then Perl code will be generated which *always* throws an exception
'perl error - EVAL_PERL not set'. If EVAL_PERL is set, then it will
generate code which tests the EVAL_PERL option in the _running_
context (which may not be the same context that compiled it), and
throws the same error is the option is not set. Note that [% RAWPERL %]
blocks are added verbatim to the generated code if the EVAL_PERL
option is set in the compiling context and no runtime check for
EVAL_PERL is made. Similarly, [% PERL %] blocks could contain a
Perl BEGIN block, e.g. "BEGIN { # subterfuge code here }" which
will always get executed at runtime, regardless of any runtime
EVAL_PERL option. Thanks to Randal Schwartz for raising this issue.
* Fixed an obscure bug in WRAPPER which was causing some variables to
have apparently strange values when within the block content. This
was due to the content being formed into a closure which was called
from within the WRAPPER template, possibly after some variable values
had been changed. e.g.
[% title = "foo" %]
[% WRAPPER outer title="bar" %]
The title is [% title %]
[% END %]
Here, the 'outer' template should be called with a 'title' value of
'bar' but with 'content' set to 'The title is foo'. Previously,
the content would have been processed from within the 'outer' template,
resulting in a 'content' value of 'The title is bar'. The behaviour is
now correct.
* Filter failures are now raised as 'filter' exception types, instead
of 'undef'.
* Applied a patch from Simon Matthews to fix some minor bugs in the
DBI plugin:
- Added _connect method to Plugin::DBI for backwards compatability with
code from version 1 of Template that subclassed the plugin
- Changed the new mothod on the DBI plugin so that it checks to see if
it is being called by a subclassed object.
- Fixed the return value in the DBI plugin when connect is called more
than once in the lifetime of the plugin
* Removed a dubious looking chomp() from Template::Plugins which may
have caused abject stringification of any error object throw by a
failed plugin constructor. Thanks to Piers Cawley for finding the
devious culprit.
* Changed ttree to not offer to create a ~/.ttreerc file if it doesn't
exist when the user has specified a '-f file' on the command line.
Thanks to Michael Stevens for raising the issue.
* Added the match($result, $expect) subroutine to Template::Test.
* Modified the final test of wrap.t to strip any trailing whitespace from
the output due to a problem with Text::Wrap under 5.005_02. Thanks to
Rob Stone for reporting the problem.
* Added documentation for DEBUG options and stderr filter. Thanks to
Piers Cawley for spotting the omission.
# Version 2.00-rc2 14th November 2000
* Added the 'prev' and 'next' methods to Template::Iterator and
Template::Plugin::DBI::Iterator to return the previous and next
items from the data set.
* Added the 'sort' and 'nsort' virtual methods for hash arrays,
thanks to a patch provided by Leon Brocard.
* Various fixes to DBI plugin, configuration and test:- modified
Makefile.PL to prompt for DBI DSN specific to user's DBD; changed
DBI plugin to accept DBI attributes (e.g. ChopBlanks) as named
parameters to connect method; fixed t/dbi.t to not munge 'user'
variable in final test; added 'ChopBlanks' attributes to satisfy
tests under certain DBD's (e.g. Pg). Thanks to Jonas Liljegren and
Chris Nandor for their efforts in finding, testing and fixing the
* Modified the XML::DOM plugin to work with XML::DOM version 1.27
which now uses blessed array references instead of hashes as the
underlying data types. Changed Makefile.PL and t/dom.t to require
version 1.27 or later.
* Changed the Template::Iterator module to *NOT* automatically expand
the contents of blessed ARRAY objects to construct the iteration data
set. The previous behaviour caused problems with modules such as
XML::DOM where a single object passed to the iterator constructor
would be expanded into a list of the member data, rather than being
treated as a single item list containing that one object. A blessed
ARRAY reference can now provide the as_list() method which the
iterator constructor will call to return list data.
* Fixed a bug in Template::Provider to ensure that template metadata
(e.g. name, modtime, etc.) is written to compiled template files.
Thanks to Steven Hetland for reporting the problem.
* Changed the Template::Directive::template() generator method to
raise an error if a context reference isn't passed to a template
subroutine as the first argument.
* Fixed t/autoformat.t to use locale dependant numerical formatting.
Note that versions of Perl prior to 5.6.0 still have problems and
will cause t/autoform.t tests 23 and 25 to fail under locales that
use a decimal separator other than '.'. The Makefile.PL will issue
a warning in such cases. Thanks to Jonas Liljegren for reporting
the problem.
* Applied a patch from Leon Brocard which corrects the behaviour of
the URL plugin to join parameters with '&amp;' instead of '&'.
* Fixed a bug in the AUTOLOAD method of the Template::Plugin base
class which caused warnings about not finding _DELEGATE pseudo-hash
method under Perl 5.6.0.
* Various minor documentation fixes, thanks to Henrik Edlund and Leon
# Version 2.00-rc1 1st November 2000
* Added the push(), pop(), unshift() and shift() virtual list methods
and fixed the parser to allow empty lists to be created (also fixed
the parser to prevent warnings being raised by empty hashes).
Updated test scripts and documentation to include examples. Thanks
to Stas Beckman for raising the issue.
* Incorporated the DBI plugin module, written by Simon Matthews. This
features a major reorganisation of the code, fixes a few bugs, removes
some lava flow, and has improved documentation and test script.
* Updated the Makefile.PL to prompt for DBI test parameters, check for
external modules (and in particular, versions which may cause problems)
and various other niceties. Also updated the README and TODO files.
* Rewrote the XML::DOM plugin, fixing the memory leakage problems and
adding the toTemplate() method and friends, as provided by Simon
Matthews. Note that it's quite easy to send Perl into a deep
recursive loop via the childrenToTemplate() and allChildrenToTemplate()
methods due to a misfeature added by abw. This will be fixed in a
future release and may result in behavioural changes to the
*children* methods, so don't rely on them too heavily for now.
* Incorporated the Dumper plugin from Simon Matthews which interfaces to
the Data::Dumper module.
* Fixed a bug in the Datafile plugin which was causing the last data field
to be ignored. Credit due (yet again!) to Simon Matthews for finding
the missing chomp().
* Fixed a bug in Template::Directive which was generating a 'Useless use
of scalar ref constructor in void context...' for empty BLOCK
* Added the Wrap and Autoformat plugins which interface to Text::Wrap
and Text::Autoformat respectively. Thanks to Robert McArthur for the
original Autoformat plugin code.
* Added the XML::XPath plugin, test script and documentation.
* Fixed a bug in the Template::Service module which was using any
non-word characters to delimit lists of PRE/POST_PROCESS files.
A value such as 'config, header.html' would be interpreted as
[ 'config', 'header', 'html' ]. It now uses the DELIMITER value
which is ':' by default, e.g. PRE_PROCESS => 'config:header.html'
is interpreted as [ 'config', 'header.html' ].
* Fixed a bug in the parser grammar which was failing to correctly
identify compound variables that contained two or more consecutive
numbers. For example, the variable [% pi.3.14 %] was being interpreted
as 'pi' . '3.14', instead of 'pi' . '3' . '14'.
* Further modified parser to accept single quoted BLOCK names that would
otherwise choke on 'illegal' characters. e.g. [% BLOCK 'foo bar' %]
* Changed the Template::Context::template() method to always throw an
exception when a template can't be found instead of simply setting
an internal error string. Modified other Template::Context and
Template::Service methods to expect this behaviour and act
accordingly. The visible impact of this is that the Template
error() method will now always return an exception object.
Previously there were certain cases where a plain error string would
have been returned.
* Change the ROOT_OPS, SCALAR_OPS, HASH_OPS and LIST_OPS virtual
method tables in Template::Stash to incorporate any existing defined
values. Previously, you had to 'use Template::Stash' before
defining any new virtual methods to prevent them being overwritten
when Template::Stash was subsequently loaded. Thanks to Chris
Nandor for identifying the problem and suggesting a fix.
* Changed BREAK directive to LAST to keep it in line with Perl (don't
know why I originally chose 'BREAK' - must have had my C head on at
the time). BREAK is still supported as an alias for LAST.
* Renamed the Template::Iterator number() method to count(), although
number() is still supported for backwards compatability. The DBI
plugin used count() instead of number() (an oversight, I think) but I
decided that count() was the better name (shorter and more obvious).
Also changed internal Template::Iterator counter variables to UPPER
CASE to allow AUTOLOAD to be more easily reused by derived iterators
such as the one for the DBI plugin.
* The Template::Plugin module is now derived from Template::Base. The
only significant ramification of this is that plugins should now
call the error() method on failure in preference to fail(). The
fail() method is still supported and delegates on to error(), but it
raises a deprecation warning.
* Fixed a bug in the Table plugin which caused an "undefined variable..."
warning to be emitted when an empty list was provided.
* Renamed 'evalperl' filter to 'perl', something that previously
couldn't be done (before ANYCASE) due to 'perl' clashing with 'PERL'
reserved word. 'evalperl' is still provided for backwards
compatability. Also added 'evaltt' as an alias for the 'eval'
filter and 'file' as an alias for 'redirect' (which I claimed to
have done back in beta 3 but obviously hadn't).
* Fixed a bug in the perl/evalperl filter which was causing a stash
reference to be bound in a closure that could later become
invalidated. This could lead to variables not getting/setting their
correct values in subsequent calls to the same filter.
* Documented the problem identified by Chris Winters where an IF
used as a side-effect to an implied SET directive doesn't behave as
expected. A directive of the form [% foo = 'bar' IF condition %]
should be written explicitly as [% SET foo = 'bar' IF condition %]
* Documented the 32k size limit (or typically less) for templates when
the INTERPOLATE option is set.
# Version 2.00 beta 5 14th September 2000
* Added define_filter($name, \&filter, $is_dynamic) method to
Template::Context to allow additional filters to be defined at any
time. Arguments are as per the FILTERS configuration option.
These filters persist for the lifetime of the processor.
* Changed the Template::Context filter() method to accept a code
reference as the filter name and use it as the filter sub. This
allows filters to be bound to template variables which are then
used as:
[% FILTER $myfilter %]
There is one catch, however. TT will automatically call a subroutine
bound to a variable when evaluated. Thus you must wrap your filter
sub in another sub: $stash->set('foo', sub { \&myfilter }); or bless
it into some class (any class) to fool TT into thinking it's not a
subroutine ref: $stash->set('bar', bless \&myfilter, 'any_old_name');
* Updated documentation for FILTER directive and FILTERS option to
reflect the above changes.
* Fixed Template::Document to run cleanly with taint checking enabled.
Unfortunately, this has been achieved by blindly untainting the
generated template Perl code before calling eval(). Given that
we're reading template source from external files, I don't think
there's any way to do reliable taint check anyway. But thankfully
we can trust the parser to generate "safe" code unless EVAL_PERL is
enabled in which case all bets are off anyway.
* Updated XML::DOM plugin to include changes made by Thierry-Michel
Barral to accept configuration options for XML::Parser.
* Fixed a bug in the Table plugin which caused the first item to be
repeated n times when n items was less than a specified number of
columns. Thanks to Andrew Williams for finding and fixing this
* The Template::Tutorial document really is included in the
distribution this time. Honest.
# Version 2.00 beta 4 12th September 2000
* Added the PROCESS config option which allows a template or templates
to be specified which is/are processed instead of the template
passed as an argument to the Template process() method. The
original template is available as the 'template' variable and can be
processed by calling INCLUDE or PROCESS as [% INCLUDE $template %].
* Changed what was the CASE option to now be enabled by default, and
then changed the name of the option to ANYCASE to make it more
obvious as to what it did. You must now specify directive keywords
(INCLUDE, FOREACH, IF, etc) in UPPER CASE only, or enable the
ANYCASE option to revert to the previous behaviour of recognising
keywords in any case. With the increase in reserved words in
version 2, there is more chance of collision with variable names.
It's a real pain not being able to have a variable called 'next', an
exception called 'perl', etc., because there's a reserved word of
the same name. Thus, keywords are now UPPER CASE only by default,
neatly side-stepping the problem.
* Changed the PERL directive so that output is generated by calling
print() instead of using the final value in the block. Implemented
by tying STDOUT to an output buffer based on a patch sent in by
Chuck Adams.
new: old:
[% PERL %] [% PERL %]
print "foo\n"; my $output = "foo\n";
... ...
print "bar\n"; $output .= "bar\n";
[% END %] $output;
[% END %]
* The IMPORT directive and magical IMPORT variable have been replaced
with a general purpose virtual hash method, import().
[% hash1.import(hash2) %] # was "hash1.IMPORT = hash2"
[% import(hash1) %] # was "IMPORT hash1" or "IMPORT = hash1"
* Modified the Template::Filters provider to examine the FILTERS
package hash reference (changed name from STD_FILTERS) each time a
filter is requested rather than copying them at construction time.
This allows new filters to be added on-the-fly. See t/filter.t for
examples and Template::Filters for more info.
* Added the 'nsort' list method which sorts items using a numerical
value sort rather than an alpha sort.
[% data = [ 1, 5, 10, 11 ] %]
[% data.sort.join(', ') %] # 1, 10, 11, 5
[% data.nsort.join(', ') %] # 1, 5, 10, 11
* Added 'div' operator to provider integer division (e.g. 'a div b' =>
'int(a / b)' and 'mod' which is identical to '%' but added for backwards
compatibility with V1.
* Changed the (undocumented) FORNEXT directive to NEXT and documented it.
* Fixed a bug in the persistent caching mechanism in Template::Provider
which was failing to write compiled template files for source templates
specifed in the form [% INCLUDE foo/bar %]. Intermediate directories
(like 'foo' in this example) weren't being created and the disk write
was failing. Thanks to Simon Matthews for identifying this problem.
* Fixed an obscure bug in the Template::Stash which was ignoring the
last element in a compound variable when followed by an empty
argument list. e.g. [% cgi.param() %] would be treated as [% cgi %].
Also fixed the DEBUG option so that undefined variables cause 'undef'
exceptions to be raised. Thanks to Jonas Liljegren for reporting the
* Added the reference operator, '\' which allows a "reference" to
another variable to be taken. The implementation creates a closure
around the referenced variable which, when called, will return the
actual variable value. It is really a form of lazy evaluation, rather
than genuine reference taking, but it looks and smells almost the same.
Primarily, it is useful for allowing sub-routine references to be
passed to another sub-routine. This is currently undocumented
because I'm not sure about the validity of adding it, but see t/refs.t
for examples for now.
* Changed parser to automatically unescape any escaped characters in
double quoted strings except for \n and \$. This permits strings to
be constructed that include tag characters. e.g.
[% directive = "[\% INSERT thing %\]" %]
* Fixed a bug in the use of the 'component' variable when the current
component is a sub-routine rather than a Template::Document.
* Added the '--define var=val' option to tpage to allow template
variables to be defined from the command line. Added support to
ttree for various new Template configuration options.
* Added $Template::Test::PRESERVE package variable which can be set to
prevent newlines in test output from being automatically mangled to
literal '\n'.
* Completed and corrected all knows bugs in the documentation which
now weighs in at around 100 pages for the module alone.
The POD documentation should now be installed by default. The
Template::Tutorial document is once again included in the
# Version 2.00 beta 3 10th August 2000
* Added the WRAPPER directive to include another template, passing the
enclosing block as the 'content' variable. e.g.
somefile: mytable:
[% WRAPPER mytable %] <table>
blah blah blah [% content %]
[% END %] </table>
This is equivalent to:
[% content = BLOCK %]
blah blah blah
[% END %]
[% INCLUDE mytable %]
* Added the [% INSERT file %] directive to insert the contents of a disk
file without processing any of the content. Looks for the file in the
INCLUDE_PATH and honours the ABSOLUTE and RELATIVE flags. Added the
insert($file) method to Template::Context which calls the new
load($file) method in Template::Provider which loads the file text
without compiling it.
* Added the DEFAULT configuration option which allows you to specify a
default template which should be used whenever a named template
cannot be found. This is ignored for templates specified with absolute
or relative filenames, or as references to an input filehandle or text.
* Added a FORNEXT directive to step on to the next iteration of a
FOREACH loop, as suggested/requested by Jo Ellen Wisnosky. I chose
FORNEXT rather than simply NEXT because 'next' is a very common
variable name but I'm open to better suggestions. Perhaps CASE
should be set by default to prevent variable conflict? This might
* Reorganised the Template::Filters modules and changed the calling
convention for requesting filters via the fetch() method. This now
expects a reference to the calling Template::Context object as the
third parameter (after filter name and reference to a list of arguments).
Static filter sub-routines are returned as before and the context has
no effect. Dynamic filter factories (denoted by a $is_dynamic flag
in the FILTER_FACTORY table) are called to create a filter sub-routine
(closure) for each request. The context is now passed as the first
parameter, followed by the expansion of any arguments. Filter
factories should return a sub-routine or (undef, $error) on error.
* Added several new filters:
- 'stderr' prints the output to STDERR (i.e. for generating output
in the Apache logfile, for example). e.g. [% message | stderr %]
- 'file' is the equivalent of the version 1 redirect() filter which
writes the output to a new file, relative to OUTPUT_PATH. Throws
a 'file' exception if OUTPUT_PATH is not set. There should perhaps
be some other way to disable this without relying on OUTPUT_PATH.
- 'eval' evaluates the input as a template and processes it. Proposed
by Simon Matthews for times when you might be returning templates
fragments from a database, for example. e.g. [% dirtext | eval %]
- 'evalperl' evaluate the input as Perl code, as suggested by Jonas
Liligren. Requires the EVAL_PERL option to be set and will throw a
'perl' error if not (see later item). e.g. [% perlcode | evalperl %]
* Fixed a bug in Template::Provider which was mangling the metadata items
for the template name and modification time. The [% %]
and [% template.modtime %] variables now work as expected.
* Added 'component' variable, similar to 'template', but which references
the current template component file or block, rather than the top-level
template. Of course, these may be one and the same if you're not nesting
any templates.
* Template::Provider now reports errors raised when re-compiling
modified templates rather than ignoring them, thanks to a patch from
Perrin Harkins.
* Fixed Template::Context to recognise the RECURSION option once more,
thanks to a patch from Rafael Kitover.
* Overloaded "" stringification of Template::Exception to call as_string(),
again thanks to Rafael. In a catch block you can now simply say
[% error %] as well as the more explicit [% error.type %] and/or
[% %].
* Changed Template module (via Template::Service) to return the
exception raised rather than a pre-stringified form. This allows
you to test the type() and/or info() if you want, or just print it
and rely on the automatic stringification mentioned above to format
it as expected. Note that the top-level process($file) method
returns a string rather than an exception if $file can't be found.
This is a bug, or a possible "gotcha" at the very least, and should
get fixed some time soon. For now, test that the error is a
reference before attempting to call info() or type().
* Fixed a bug preventing literal newlines from being used in strings.
Thanks to Simon Matthews for bringing it to my attention by calling
my hotel room at the Perl Conference and saying "Hello? Is that the
Template Toolkit Helpdesk? I have a bug to report..." :-)
(I fixed it on his laptop a few minutes later - good service, eh?)
* Changed Template::Parser to not compile PERL or RAWPERL blocks if
EVAL_PERL is not set. Previously they were compiled but switched out
at runtime. This was erroneous as rogue BEGIN { } blocks could still
be executed, as noted by Randal Schwartz. Any PERL or RAWPERL blocks
encountered when EVAL_PERL is disabled will now cause a 'perl' exception
to be thrown.
* Added a define_block($name, $block) option to Template::Context to
add a definition to the local BLOCKS cache. $block can be a reference
to a template sub-routine or Template::Document object or template
text which is first compiled.
* Any other errors thrown in a PERL blocks (assuming EVAL_PERL set)
are now left unchanged. Previously, these were converted to 'perl'
exceptions which prevented exceptions of other kinds being throw
from within Perl code.
* Applied a patch from Chris Dean to fix a bug in the list 'sort'
method which was converting a single element list into a hash. The
sort now does nothing unless there's > 1 elements in the list.
* Changed Template::Stash set() method to append the assigned value to
the end of any arguments specified, rather than prepending it to the
front. e.g. The foo() method called by [%, y) = z %] now
receives arguments as foo(x, y, z) instead of foo(z, x, y).
* Changed Template::Base::error() to accept a reference (e.g. exception)
as the first parameter. In this case, no attempt is made to
concatenate (and thereby stringify) the arguments.
* Added a direct stash() accessor method to Template::Context rather
than relying on the slower AUTOLOAD method.
* Added an iterator() method to Template::Config to require
Template::Iterator and instantiate an iterator, and changed
generated code for FOREACH to call this factory method. This fixes
a bug with pre-compiled (i.e persistent) templates which were
failing if Template::Iterator wasn't already loaded. Thanks to Doug
Steinwand, Rafael Kitover and Jonas Lilegren who all identified the
problem and hounded me until I fixed it. :-)
* Fixed a problem with persistent templates not being reloaded due to
the %INC hash. This caused 1 to be returned from require() instead
of the compiled template.
* Added ABSOLUTE and RELATIVE options to tpage by default.
* Applied various documentation and test patches from Leon Brocard.
Fixed docs to quote dotted exception types to prevent string
concatenation, as noted by Randal Schwartz. Generally added a
whole lot more documentation.
# Version 2.00 beta 2 14th July 2000
* Added COMPILE_DIR option. This allows you to specify a separate
directory in which compiled templates should be written. The COMPILE_DIR
is used as a root directory and each of the INCLUDE_PATH elements is
created below that point. e.g. the following options
COMPILE_DIR => '/tmp/ttcache',
INCLUDE_PATH => '/user/foo/bar:/usr/share/templates',
would create the following cache directories:
Templates originating from source files in the INCLUDE_PATH are thus
written in their compiled form (i.e. Perl) to the relevant COMPILE_DIR
directory. The COMPILE_EXT option may also be used in conjunction with
COMPILE_DIR to append a filename extension to all compiled files.
* Fixed memory leaks caused by the huge circular reference that is the
Template::Provider's linked list of cache slots. Added a DESTROY method
which walks the list and explicitly breaks the chains (i.e. the NEXT/PREV
links), thus allowing the compiled Template::Document objects to be
correctly destroyed and their memory repooled. Thanks to Perrin Harkins
for spotting the problem.
* Added a work-around in Template::Stash _dotop() to the problem of the
CGI module denying membership of the UNIVERSAL class on subsequent calls
to UNIVERSAL::isa($cgi, 'UNIVERSAL'). It works correctly the first time,
but returns false for all subsequent calls. Changed this generic
"is-an-object" test to UNIVERSAL::can($cgi, 'can') on the suggestion
of Drew Taylor who identified the problem.
* Added t/macro.t to test MACRO directive, t/compile4.t and t/compile5.t
to test the COMPILE_DIR option.
* More complete documentation, but not yet fully complete.
# Version 2.00 beta 1 10th July 2000
* Template::Context include()/process() now works with raw CODE refs.
* now prefixes OUTPUT with the OUTPUT_PATH when OUTPUT
is a file name.
* Cleaned up Template::Iterator. Now derived from Template::Base.
Removed ACTION and ORDER now that they are supported as list pseudo
methods in the Stash LIST_OPS.
* Fixed bug in Provider preventing updated files from being automatically
reloaded. Thanks to Perrin Harkins who provided the patch.
* Fixed bug in Template::Plugin::Datafile which was preventing a comment
from being placed on the first line of the file.
* Fixed bug in parse grammer preventing commas in a META list
* Added cache persistence by writing real Perl to file (rather than
the previous Data::Dumper dump of the opcode tree). Had to
re-organise a bunch of code around the parser/provider/document.
Activated by COMPILE_EXT configuration item.
* Added a work-around in Template::Stash to the problem of CGI disclaiming
membership of the UNIVERSAL class after the first method call.
* Added AUTO_RESET option which is enabled by default. Disable this
(AUTO_RESET => 0) for block persistence across service invocations.
* Fixed \@ quoting (and others) in Directive thanks to Perrin Harkins
who reported the bug and Chuck Adams who provided a patch.
* Added Date plugin and test, as provided by Thierry-Michel Barral.
* Integrated changes to Template::Test from version 1.07 and beyond. Now
supports -- process -- option in expect, mainly for use of t/date.t et al.
* Integrated new upper and lower filters from 1.08, and '|' alias for FILTER
from 1.07.
* Added new directive.t test to test chomping and comments.
* BLOCKS can now be defined as template text which gets automatically
compiled into a Template::Document object.
* Integrated XML plugins and tests from version 1.07
* Fixed TRIM option to work with all BLOCKs and templates. Moved TRIMing
operation into context process() and include() methods. Also changed
service to call $context->process($template) rather than call the sub/
doc itself, thus ensuring that the output can get TRIMmed.
* Updated
* Added '--define' option to ttree.
* Integrated various plugins and filters from v1.07
* Moved Template::Utils::output into and got rid of
Template::Utils altogether.
* Fixed bug in Context filter() provider method which wasn't caching
filters with args.
* [% CASE DEFAULT %] is now an alias for [% CASE %] (the default case),
in consistency with [% CATCH DEFAULT %] / [% CATCH %]
# Version 2.00 alpha 1
* first public alpha release of Version 2.00
# VERSION 2.00
# The following list outlines the major differences between version 1.*
# and version 2.00 of the Template Toolkit.
New Language Features
* New SWITCH / CASE statement. SWITCH takes an expression, CASE takes
a value or list of values to match. CASE may also be left blank or
written as [% CASE default %] to specify a default match. Only one
CASE matches, there is no drop-through between CASE statements.
[% SWITCH myvar %]
[% CASE value1 %]
[% CASE [ value2 value3 ] %] # multiple values to match
[% CASE myhash.keys %] # ditto
[% CASE %] # default, or [% CASE default %]
[% END %]
* New TRY / CATCH / FINAL construct for fully functional, nested
exception handling. The block following the TRY is executed and
output if no exceptions are throw. Otherwise, the relevant CATCH
block is executed. CATCH types are hierarchical (e.g 'foo' catches
'') or the CATCH type may be left blank or specified as [%
CATCH default %] to provide a default handler. The contents of a
FINAL block, if specified, will be processed last of all, regardless
of the result (except an uncaught exception which is throw upwards
to any enclosing TRY block).
[% TRY %]
[% CALL somecode %] # may throw an exception
[% INCLUDE someblock %] # may have a [% THROW ... %] directive
...and so on...
[% CATCH file %] # catch system-generated 'file' exception
[% CATCH DBI %] # catch 'DBI' or 'DBI.*'
[% CATCH %] # catch anything else
[% FINAL %] # optional
All done!
[% END %]
* New CLEAR directive to clear the current output buffer. This is typically
used in a CATCH block to clear the output of a failed TRY block. Any output
generated in a TRY block up to the point that an exception was thrown will
be output by default. The [% CLEAR %] directive in a catch block clears
this output from the TRY block.
[% TRY %]
blah blah blah, this is the current output block
[% THROW some.error 'Danger Will Robinson!' %]
not reached...
[% CATCH %]
[% # at this point, the output block contains the 'blah blah...' line
# up to the point where the THROW occured, but we don't want it
Here we can add some more text if we want...
[% END %]
In general, the CLEAR directive clears the current output from the
template or enclosing block.
* New META directive allowing you to define metadata items for your
templates. These are attached to the compiled template and wrapped
up as a Template::Document object. The 'template' variable is a
reference to the current parent document and metadata items may be
accessed directly. Of particular note is the fact that the
'template' variable is correctly defined for all PRE_PROCESS and
POST_PROCESS headers. Thus, your headers and footers can access
items from the main template (e.g. title, author, section, keywords,
flags, etc) and display them or act accordingly.
title = 'This is a Test'
author = 'Andy Wardley'
copyright = "2000, Andy Wardley"
<h1>[% template.title %]</h1>
blah blah
header: (a PRE_PROCESS template)
<head><title>[% template.title %]</title></head>
footer: (a POST_PROCESS template)
&copy; Copyright [% template.copyright or '2000, MyCompany' %]
* New RAWPERL ... END block directive allows you to write raw Perl
code which is integrated intact and unsullied into the destination
template sub-routine. The existing PERL ... END directive continues
to be supported, offering runtime evaluation of a block which may
contain other template directives, etc, which are first evaluated
(e.g. PERL...END processes the block and filters the output into
Perl evaluation at runtime).
* New INSERT directive which inserts the contents of a file without
processing it.
* New WRAPPER directive which processes the following block into the
'content' variable and then INCLUDEs the named file.
[% WRAPPER table %]
blah blah blah
[% END %]
[% BLOCK table %]
[% content %]
[% END %]
* Comments now only extend to the end of the current line.
[% # this is a comment
a = 10
# so is this
b = 20
Placing the '#' character immediately inside the directive will comment
out the entire directive
[%# entire directive
is ignored
* The TAGS directive can now be used to switch tag styles by name.
Several new tag styles are defined (e.g. html, asp, php, mason).
[% TAGS html %]
<!-- INCLUDE header -->
* The output from any directive or block can now be captured and assigned to
a variable.
[% htext = INCLUDE header %]
[% btext = BLOCK %]
blah blah
[% x %] [% y %] [% z %]
[% END %]
# you can even assign the output of loops, conditions, etc.
[% numbers = FOREACH n = [2, 3, 5, 7, 11, 13] %]
blah blah [% n %]
[% END %]
* The handling of complex expressions has been improved, permitting
basic directives to contain logical shortcut operators, etc. All
binary operators now have the same precedence rules as Perl.
[% foo or bar %] # GET foo, or bar if foo is false (0/undef)
[% CALL func1 and func2 %] # func2 only called if func1 returns true
[% name = or cgi.param('id') %].
* A new "x ? y : z" operation is provided as a shorthand for
"if x then y else z"
[% foo = bar ? baz : qux %]
* A leading '$' on a variable is now used to indicate pre-interpolation
of that element. This simplifies the syntax and makes it consistent
with double-quoted string interpolation and text block interpolation
via the INTERPOLATE flag. If you've been relying on the version 1
"feature" that ignores the leading '$' then you'll need to change your
templates to remove the '$' characters (except where you really want
them) or set the V1DOLLAR flag to 1 to revert to the version 1
behaviour. See the 'Gotchas' section below for more details.
# version 1
[% hash.${key} %] [% hash.${complex.key} %]
# version 2
[% hash.$key %] [% hash.${complex.key} %]
* Various new pseudo-methods have been added for inspecting and manipulating
data. The full list now looks something like this:
[% var.defined %] # variable is defined
[% var.length %] # length of string
[% var.split(delim, limit) %] # split string as Perl does
[% hash.keys %] # return list of hash keys
[% hash.values %] # ditto hash values
[% hash.each %] # ditto keys and values
[% hash.import(hash2) %] # merge hash2 into hash
[% list.size %] # number of items in list
[% list.max %] # last item number (size - 1)
[% list.first %] # first item
[% list.last %] # last item
[% list.push(item) %] # add item to end
[% list.pop %] # remove item from end
[% list.unshift(item) %] # add item to front
[% list.shift %] # remove item from front
[% list.reverse %] # return reversed order
[% list.sort(field) %] # return alpha sorted order
[% list.nsort(field) %] # return numerical sorted order
[% list.join(joint) %] # return items joined into single string
Configuration Options
* Template blocks may be pre-defined using the new BLOCKS option. These
may be specified as template text or as references to sub-routines or
Template::Document objects.
my $template = Template->new({
header => '<html><head><title>[% title %]</title></head><body>',
footer => '</body></html>',
funky => sub { blah_blah($blah); return $some_text },
* Automatic error handling can be provided with the ERROR option. This
allows you to specify a single template or hash array of templates which
should be used in the case of an uncaught exception being raised in the
a template. In other words, if something in one of your templates
throws a 'dbi' error then you can define an ERROR template to catch
this. The original template output is discarded and the ERROR template
processed in its place. PRE_PROCESS and POST_PROCESS templates (e.g.
header and footers) are left intact. This provides a particularly
useful high-level error handling abstraction where you simply create
templates to handle particular exceptions and provide the mapping
through the ERROR hash.
my $template = Template->new({
ERROR => {
dbi => 'error/database.html', # DBI error
'user.pwd' => 'error/badpasswd.html', # invalid user password
user => 'user/index.html', # general 'user' handler
default => 'error/error.html', # default error template
* The INCLUDE_PATH is now fully dynamic and can be changed at any time.
The new Template::Provider which manages the loading of template files
will correctly adapt to chahges in the INCLUDE_PATH and act accordingly.
* The LOAD_TEMPLATES option allows you to specify a list of one or more
Template::Provider object which will take responsibility for loading
templates. Each provider can have it's own INCLUDE_PATH, caching
options (e.g CACHE_SIZE) and so on. You can sub-class the
Template::Provider module to allow templates to be loaded from a
database, for example, and then define your new provider in the
LOAD_TEMPLATES list. The providers are queried in order as a "Chain
of Responsiblity". Each may return a compiled template, raise an
error, or decline to serve the template and pass control onto the
next provider in line.
* The CACHE_SIZE option defines a maximum number of templates that will
be cached by the provider. It is undefined by default, causing all
templates to be cached. A value of 0 disables caching altogether while
a positive integer defines a maximum limit. The cache (now built into
Template::Provider) is much smarter and will automatically reload and
compile modified source templates.
* The Template::Provider cache can write compiled templates (e.g. Perl code)
to disk to create a persistent cache. The COMPILE_EXT may be used to
specify a filename extension (e.g. '.ttc') which is used to create
compiled template files. These compiled template files
can then be reloaded on subsequent invocations using via Perl's
require() (which is about as fast as it can get). The Template::Parser
and Template::Grammar modules are loaded on demand, so if all templates
have been pre-compiled then the modules don't get loaded at all. This
is a big win, given that Template::Grammar is the biggy.
* The ABSOLUTE and RELATIVE options are now used to enable the loading of
template files (via INCLUDE or PROCESS) that are specifies with absolute
(e.g. /tmp/somefile) or relative (e.g. ../tmp/another) filenames. Both
are disabled by default.
* The LOAD_PLUGINS option is similar to LOAD_TEMPLATES but allows you
to specify one or more plugin providers. These take responsibility
for loading and instantiating plugins. The Template::Plugins module
is the default provider and multiplexes requests out to other
Template::Plugin::* plugin modules. Loading of plugins has been
simplified and improved in general The PLUGINS option can be used to
map plugin names to specific modules and PLUGIN_BASE can map plugins
into particular namespaces. The LOAD_PERL option can be used to
load (almost) any regular Perl module and use it as a plugin.
* The LOAD_FILTERS option is similar to LOAD_TEMPLATES and LOAD_PLUGINS,
allowing one or more custom providers to be specified for providing
filters. The Template::Filters module is the default provider here.
* The TOLERANT option can be used to tailor the behaviour of providers
(e.g. Template::Provider, Template::Plugins, Template::Filters) when
they encounter an error. By default, providers are not TOLERANT (0)
and will report all failures as errors. When TOLERANT is set to 1,
they will ignore errors and return STATUS_DECLINED to give the next
provider a chance to deliver a valid resource.
* The INTERPOLATE option is now automatically disabled within PERL and
RAWPERL blocks to prevent Perl $variables from being interpreted as
template variables.
This $var will get interpolated...
[% PERL %]
# but these won't
my $foo = 'some value';
my $bar = 'another value';
# etc...
[% END %]
now we're interpolating variables again, like $var
* Added the TRIM option to automatically removed leading and trailing
whitespace from the output of templates and BLOCKs.
* The CASE option has now been obsoleted and replaces by the ANYCASE
option. See comments elsewhere in this document ('Gotchas' below and
notes for 2.00 beta 4) for further details.
Templates Compiled to Perl Code
Templates are now compiled to Perl code, with credit and respect due
to Doug Steinwand for providing an implementation around which the
new parser was built. This brings a number of important benefits:
* Speed and Memory Efficiency
Version 1 used a list of opcodes to represent directives and
lower-level operations. These were evaluated by the hideously
contrived, and darkly sinister Template::Context::_evaluate()
method. In version 2, all templates are parsed and rebuilt as Perl
code. This is then evaluated and stored as a reference to a Perl
sub-routine which can then be executed and re-executed significantly
faster and with far less memory overhead.
* Persistence.
Once a template has been compiled to Perl code it can be saved to
disk as a "compiled template" by defining the COMPILE_EXT option.
This allows you to specify a filename extension (e.g. '.ttc') which
is added to the template filename and used to create a new file
containg the Perl code. Next time you use the template, even if
you've shut down your program/server/computer in the mean time, the
compiled template is there in a file as Perl code and is simply
require()d and executed. It all happens significantly faster
because there's no Template::Parser to run. In fact, if all your
templates are "compiled" on disk then the Template::Parser and
Template::Grammar modules won't even be loaded, further reducing
startup time and memory consumption (the grammar file, in particular
is rather large). The Template::Provider module handles the
loading, caching and persistence of templates, and will examine file
timestamps and re-compiled modified templates as required.
* Flexibility.
Because "compiled templates" are now nothing more than Perl
sub-routines, you can use anyone or anything to generate them and
run them all under the same roof. Different parser back-ends can
generate Perl code optimised for speed or functionality, for
example. Or different parsers can compile different template
languages (PHP, ASP, Mason, roll-your-own, etc.) and run them
alongside regular templates. Or if you don't trust a parser, you
can even write your own Perl code and have your templates execute as
fast as the code you can write.
Other Enhancements and Internal Features
* Templates (i.e. sub-routines) now return their generated output,
rather than sending it to $context->output(). This speeds things
up and makes the code simpler, as well as allowing greater
flexibility in how template sub-routines can work.
* Exceptions are now raised via Perl's die() and caught by an
enclosing eval { } block. Again, this simplifies the code generated
and improves runtime efficiency. The [% RETURN %] and [% STOP %]
directives are now implemented as special case exceptions which are
caught in the appropriate place and handled accordingly.
* Local named BLOCK definitions are better behaved and don't permanently
mask any real files. BLOCK definitions remain local to the template in
which they're defined, although they can be accessed from templates
INCLUDEd or PROCESSed from within. The PROCESS directive will export
defined BLOCKs to the caller (as with variables) whereas INCLUDE will
keep them "private".
* The Template::Stash object now encapsulates all the magical variable
resolution code. Both simple and compound variables can be accessed
or updated using the get() and set() methods, with all variable binding
magic happening automatically.
* The Template::Context object is now greatly simplified. This acts
as a general interface to the Template Toolkit functionality, being
a collection of the various other modules that actually implement
the functionality (e.g. Template::Stash, Template::Provider,
Template::Document, Template::Plugins, etc.)
* The Template::Provider object provides a general facility for
retrieving templates from disk (or other source), and if necessary
compiling via a call to a Template::Parser helper object. Multiple
Template::Provider objects may be chained together, each with their
own caching options, and so on.
* The Template::Parser object now compiles template text into Perl
code and then evaluates it into a sub-routine reference using Perl's
eval(). This is then wrapped up into a Template::Document object,
including any metadata items and/or additional named BLOCKs defined
in the input template.
* The Template::Document object is a thin wrapper around a compiled
template sub-routine. It provides a process() method for processing
the template and a blocks() method for returning a reference to the
hash array of any additional named BLOCKs defined in the original
template text. An AUTOLOAD method returns values of metadata items,
allowing a Template::Document reference to be used as the 'template'
* The Template::Service module provides a high-level service for
processing templates, allowing PRE_PROCESS and POST_PROCESS templates
to be specified along with an ERROR handling hash.
* The Template::Base module defines a common base class for many of
the toolkit modules. It implements shared functionality such as a
constructor, error reporting and handling, etc. Modules are now
much easier to sub-class, all using separate new() and _init()
* The Template::Config module provides methods for loading and
instantiating different Template Toolkit modules. Using this
factory-based approach makes it far easier to change the default
object class for a specific part of the toolkit. e.g.
use Template;
use Template::Config;
$Template::Config::PARSER = 'MyOrg::Template::MyParser';
# $tt object will create and use a MyOrg::Template::MyParser
# object as PARSER
my $tt = Template->new({ ... })
* The Template::Test module has been enhanced to make it easier to test
more advanced TT features. You can now define multiple TT processors
and switch between them for different test with the '-- use name --'
directive. Also added the '-- process --' directive which can be
added after '-- expect --' to hav the expected output processed by
TT before comparison.
* The Template module remains, as it ever was, a simple front-end to
the Template Toolkit. This creates a single Template::Service to
which it delegates control for processing templates. Output is
returned according to the OUTPUT options specified for the module
and/or any output option passed explicitly to the process() method.
New Filters
* 'upper' and 'lower' filters perform case folding of text.
* 'eval' can be used to evaluate Template Toolkit directives at runtime.
* 'perl' evaluates Perl code if (and only if) the EVAL_PERL flag is set.
* 'stderr' is a simple filter to STDERR.
* 'file' is a new alias for the 'redirect' filter. The OUTPUT_PATH option
must be set.
New Plugins
* The DBI plugin is now distributed with the Template Toolkit.
* The Date plugin formats dates and times via the POSIX strftime() sub.
* The Iterator plugin provides access to the Template::Iterator module.
* The Dumper plugin provides an interface to the Data::Dumper module.
* The Wrap and Autoformat plugins interface to the Text::Wrap and
Text::Autoformat modules respectively.
* The XML::DOM and XML::XPath plugins provide interfaces to the relevant
XML modules.
Utility Scripts
* Added the '--define var=val' option to ttree.
Things that have changed between version 1 and 2 that might catch you
* Bare CATCH blocks are no longer permitted and must be explicitly
scoped with a matching TRY. In most cases, this simply means adding
a [% TRY %] to the start of any templates that define CATCH blocks,
and ensuring that the CATCH blocks are moved to the end of the file
(or relevant place).
# version 1 - no longer supported
blah blah blah...some error occurs
[% CATCH some_kind_of_error %]
handler template...
[% END %]
# version 2
[% TRY %]
blah blah blah...some error occurs...
[% CATCH some_kind_of_error %]
handler template...
[% END %]
Also be aware that this may change the expected output in case of
errors. By default, all output in the TRY block up to the point of
error will be returned, with the relevant catch block, and then and
further template output appended. You can use [% CLEAR %] within a
CATCH block to clear the output from the TRY block, if you prefer.
TRY blocks can be nested indefinately.
* The ERROR directive is no longer supported. It was very ill-defined
anyway and serves no purpose that can't be acheived by defining
custom filters, error handlers bound to template variables, or
whatever. I haven't implemented any special error or logging
facilities, other than the general purpose exception handling, but
welcome any thoughts on what or if anything else is needed.
* The ERROR option is also different. It could previously be used
to specify an error handling sub-routine, but is no longer required
(see previous point). The ERROR option in version 2 is used to
define a map of error types to template names for automatic
redirection for error handling.
* The current exception caught in a catch block is now aliased to the
variable 'error' rather than 'e'. This is much more logical, IMHO,
and was only prevented previously by 'error' being a reserved word.
Note that 'e' is still defined, in addition to 'error'. This may be
deprecated at some point in the future.
* The use of a leading '$' on variables is no longer optional, and
should only be used to explicitly to indicate interpolatation of a
variable name. Most of the time you *don't* want to do this, so
leave the '$' off. This represent a slight shift away from the
(optional) Perlness of the language, but I think it's a necessary
step to improve the clarity and consistency of the language.
As previously discussed on the mailing list, in interpolated text
(i.e. a "double quoted" string or regular template text with
INTERPOLATE set), both '$foo' or '${foo}' are interpolated as the
value of the variable 'foo'. This is good because it is a de-facto
standard, consistent with Perl, shell, etc. But inside a directive,
[% $foo %] and [% ${foo} %] mean different things, the first being
equivalent to [% foo %] or [% GET foo %] (the leading '$' is
ignored) but the second actually fetching a variable whose name is
stored in the variable 'foo'. In other words, '${foo}' interpolates
to the value of foo ('bar', say) and then this is used as the
parameter to GET (which itself is optional). Thus, in this case, [%
${foo} %] is [% GET ${foo} %] is [% GET bar %].
This makes more sense if you look at the common example of
accesing an entry from a hash array using the value of an variable
as the key (e.g. $hash->{ $key }). In version 1, the leading '$' on
variables is ignored, meaning that the following are NOT identical.
# version 1
[% hash.$key %] # ERROR - '$' ignored => [% hash.key %]
[% hash.${key} %] # OK - '$key' is interpolated first
It gets more confusing if you excercise your right to add optional
leading '$'s in other places (which is one reason why I've always
suggested against their use).
# version 1 - same as above
[% $hash.$key %]
[% $hash.${key} %]
In particular, that last example should demonstrate the
inconsistency. Unlike interpolated text, '$...' and '${...}' are
not treated the same and '$hash' is not interpolate while '${key}'
is. The only consistent solution I can see to this is to make both
'$xxx' and '${xxx}' indicate interpolation in all cases, so that's
what I've done. In version 2, the syntax becomes a lot clearer and
aligns more closely to a markup language than a programming
language. I think this is a Good Thing, but let me know what you
Here's the Version 2 summary, assuming INTERPOLATE is set.
# version 2
my name is $name
my name is $
my name is ${}
[% GET name %] [% name %]
[% GET %] [% %]
[% GET people.fred %] [% people.fred %]
[% GET people.$name %] [% people.$name %]
[% GET people.${} %] [% people.${} %]
[% INCLUDE header
title = "Home Page for $name"
[% INCLUDE header
title = "Home Page for $"
[% INCLUDE header
title = "Home Page for ${}"
* Changed default TAG_STYLE to only recognise [% ... %] and not the MetaText
compatability %% ... %% style. Set TAG_STYLE => 'template1' to accept both,
or 'metatext' for just %% ... %%
* Changed how error/return values should be returned from user code.
All errors should be thrown via one of the following:
die $error_msg;
die (Template::Exception->new($type, $info));
$context->throw($type, $info);
* USERDIR and USERBLOCK are not supported (they were experimental and
undocumented, anyway)
* $Template::Directive::While::MAXITER is now
$Template::Directive::WHILE_MAX and may change again.
* into() filter is now obsolete. You can now simply assign the output of
another directive or block to a variable.
[% x = INCLUDE foo %]
[% y = BLOCK %]
blah blah blah
[% END %]
* The CASE option has been removed and replaced with the ANYCASE option
which is the logical opposite. Directive keywords should now be UPPER
CASE by default and the ANYCASE option can be enabled to revert to
the previous behaviour of accept keywords in any case.
* The IMPORT directive and magical variable have been removed and
replaced by a general purpose virtual hash method, import().
[% IMPORT myhash %] should now be written [% import(myhash) %]
and [% myhash.IMPORT = another.hash %] should be written as
[% myhash.import(another.hash) %]