Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bumped version number to 2.24, updated Changes, README, etc

  • Loading branch information...
commit b95e0ae29b320204b30afc1490f1baa20bafb483 1 parent 6ad0b49
@abw authored
Showing with 100 additions and 97 deletions.
  1. +6 −6 Changes
  2. +3 −3 HACKING
  3. +20 −20 INSTALL
  4. +26 −23 README
  5. +45 −45 lib/Template.pm
View
12 Changes
@@ -11,7 +11,7 @@
#========================================================================
#-----------------------------------------------------------------------
-# Version 2.24 - ??
+# Version 2.24 - 8th February 2012
#------------------------------------------------------------------------
* Added text virtual methods: upper, lower, ucfirst, lcfirst, squote,
@@ -114,7 +114,7 @@
* Replaced a whole bunch of UNIVERSAL::isa() calls with blessed/isa
-* Applied a patch from Norbert Buchm�ller to prevent the #line markers
+* Applied a patch from Norbert Buchmüller to prevent the #line markers
from being whitespaced away from the first column.
https://rt.cpan.org/Ticket/Display.html?id=46269
@@ -327,7 +327,7 @@ ttree
but via a configuration option.
https://rt.cpan.org/Ticket/Display.html?id=30760
-* Applied a patch from �ric Cholet to add the --encoding option to ttree.
+* Applied a patch from Éric Cholet to add the --encoding option to ttree.
http://lists.tt2.org/pipermail/templates/2008-August/010369.html
@@ -335,7 +335,7 @@ ttree
# Version 2.19 - 27th April 2007
#------------------------------------------------------------------------
-* Applied a patch to t/fileline.t from Steffen M�ller which fixes the
+* Applied a patch to t/fileline.t from Steffen Müller which fixes the
problems running on Win32 with backslashes in paths.
https://rt.cpan.org/Ticket/Display.html?id=20488
@@ -1329,7 +1329,7 @@ Miscellaneous
* 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
+* 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
@@ -1387,7 +1387,7 @@ Miscellaneous
* 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.
+ Yann Kerhervé for the patch.
#------------------------------------------------------------------------
View
6 HACKING
@@ -1,9 +1,9 @@
Template Toolkit
- Version 2.23
+ Version 2.24
- January 2012
+ February 2012
Copyright (C) 1996-2012 Andy Wardley. All Rights Reserved
@@ -25,7 +25,7 @@ but the code is well documented and generally easy to follow. Don't
be afraid to use the source, Luke.
The internals document also contains information about preparing and
-applying patches, updating the documentation and various other
+applying patches, updating the documentation and various other
useful tips.
View
40 INSTALL
@@ -1,9 +1,9 @@
Template Toolkit
- Version 2.23
+ Version 2.24
- January 2012
+ February 2012
Copyright (C) 1996-2012 Andy Wardley. All Rights Reserved
@@ -30,12 +30,12 @@ Available from CPAN in:
To install the Template Toolkit from the command line:
- $ tar zxf Template-Toolkit-2.23.tar.gz
- $ cd Template-Toolkit-2.23
+ $ tar zxf Template-Toolkit-2.24.tar.gz
+ $ cd Template-Toolkit-2.24
$ perl Makefile.PL
$ make
$ make test
- $ make install
+ $ make install
The Makefile.PL will prompt for any additional configuration options.
@@ -49,7 +49,7 @@ further information about installation.
PREREQUISITES
-------------
-The Template Toolkit is written entirely in Perl and should run on any
+The Template Toolkit is written entirely in Perl and should run on any
platform on which Perl is available. It requires Perl 5.006 or later.
The 'ttree' utility uses the AppConfig module (version 1.56 or above)
@@ -70,7 +70,7 @@ and Template::Manual::Plugins for further details.
OBTAINING AND INSTALLING THE TEMPLATE TOOLKIT
---------------------------------------------
-The latest release version of the Template Toolkit can be downloaded
+The latest release version of the Template Toolkit can be downloaded
from any CPAN site:
http://www.cpan.org/modules/by-module/Template/
@@ -85,19 +85,19 @@ The Template Toolkit is distributed as a gzipped tar archive file:
Template-Toolkit-<version>.tar.gz
-where <version> represents the current version number, e.g. 2.23.
+where <version> represents the current version number, e.g. 2.24.
To install the Template Toolkit, unpack the distribution archive to
create an installation directory. Something like this:
- $ tar zxf Template-Toolkit-2.23.tar.gz
+ $ tar zxf Template-Toolkit-2.24.tar.gz
or
- $ gunzip Template-Toolkit-2.23.tar.gz
- $ tar xf Template-Toolkit-2.23.tar
+ $ gunzip Template-Toolkit-2.24.tar.gz
+ $ tar xf Template-Toolkit-2.24.tar
You can then 'cd' into the directory created,
- $ cd Template-Toolkit-2.23
+ $ cd Template-Toolkit-2.24
and perform the usual Perl installation procedure:
@@ -123,7 +123,7 @@ For advice on using Perl under Microsoft Windows, have a look here:
http://win32.perl.org/
-If you're using Strawberry Perl then you can install the Template
+If you're using Strawberry Perl then you can install the Template
Toolkit using the CPAN module as described above.
If you're using ActivePerl then you can install it using the Perl Package
@@ -150,16 +150,16 @@ CONFIGURATION
This section covers the configuration of the Template Toolkit via
the Makefile.PL program. If you've successfully run this and didn't
-have any problems answering any of the questions then you probably
+have any problems answering any of the questions then you probably
don't need to read this section.
The Makefile.PL Perl program performs the module configuration and
generates the Makefile which can then be used to build, test and
-install the Template Toolkit.
+install the Template Toolkit.
$ perl Makefile.PL
-The Template Toolkit now boasts a high-speed implementation of
+The Template Toolkit now boasts a high-speed implementation of
Template::Stash written in XS. You can choose to build this as
an optional module for using explicitly as an alternative to
the regular pure-perl stash module. In additional, you can opt
@@ -169,8 +169,8 @@ Toolkit run twice as fast!
When prompted, answer 'y' or 'n' to build and optionally use
the XS Stash module by default:
- Do you want to build the XS Stash module? [y]
- Do you want to use the XS Stash for all Templates? [n]
+ Do you want to build the XS Stash module? [y]
+ Do you want to use the XS Stash for all Templates? [n]
BUILDING AND TESTING
--------------------
@@ -179,8 +179,8 @@ This section describes the "make" and "make test" commands which build
and test the Template Toolkit. If you ran these without incident,
then you can probably skip this section.
-The 'make' command will build the Template Toolkit modules in the
-usual manner.
+The 'make' command will build the Template Toolkit modules in the
+usual manner.
make
View
49 README
@@ -1,9 +1,9 @@
Template Toolkit
- Version 2.23
+ Version 2.24
- January 2012
+ February 2012
Copyright (C) 1996-2012 Andy Wardley. All Rights Reserved
@@ -20,7 +20,7 @@ Toolkit from the command line like so:
$ cpan Template
Please see the separate INSTALL file for further information on installing
-the Template Toolkit, including what to do if you don't have the CPAN
+the Template Toolkit, including what to do if you don't have the CPAN
module installed, and/or installation on MS Windows.
@@ -37,20 +37,23 @@ LaTeX, and so on.
It can be used as a stand-alone Perl module or embedded within an
Apache/mod_perl server for generating highly configurable dynamic web
content. A number of Perl scripts are also provided which can greatly
-simplify the process of creating and managing static web content and
+simplify the process of creating and managing static web content and
other offline document systems.
WHAT'S NEW?
-----------
+Version 2.24 adds some new text virtual methods and fixes a silly bug in the
+Makefile.PL.
+
Version 2.23 is a maintenance release which fixes a few bugs, including one
in the XS Stash which caused problems when using third party modules (e.g.
DateTime) which use the string-based form of eval.
-Version 2.22 is mostly a bug fixing release. The XS Stash now works with
-utf8 data. Tests that were failing on Win32 platforms have been fixed. Pod
-coverage and quality tests have been disabled except for release testing.
+Version 2.22 is mostly a bug fixing release. The XS Stash now works with
+utf8 data. Tests that were failing on Win32 platforms have been fixed. Pod
+coverage and quality tests have been disabled except for release testing.
The Autoformat plugin has been moved into a separate distribution.
Version 2.21 featured a complete clean-out of all the old HTML documentation,
@@ -70,14 +73,14 @@ plugins. The HTML documentation, examples, libraries and other bits
and pieces are still provided with the distribution, but are no longer
installed by the Makefile.PL. If you want them (and very few people do,
it seems), then you'll need to dig them out of the distribution by yourself
-(or uncomment the commented-out lines in Makefile.PL that handle the
+(or uncomment the commented-out lines in Makefile.PL that handle the
installation). This has been done in an effort to simplify the installation
process. All of the HTML documentation is available online at http://tt2.org/
Version 2.19 fixed some minor bugs in both Perl and XS versions of the Template
Stash, and fixed a problem with a test in the test suite failing under Win32.
It also added the url filter as a version of what the uri filter used to do
-before we fixed it to do the right thing.
+before we fixed it to do the right thing.
Version 2.18 fixes a number of minor bugs. It also includes a modification to
the parser grammar so that you can write expressions as arguments to
@@ -91,7 +94,7 @@ patches and closes all open bugs listed on http://rt.cpan.org/ It
includes:
* XS Stash: enhancements include support for tied hashes/arrays
- and "fallback" methods on objects (e.g. accessing hash and
+ and "fallback" methods on objects (e.g. accessing hash and
list items and calling virtual methods)
* Virtual Methods: added the scalar.remove, scalar.substr,
@@ -101,7 +104,7 @@ includes:
list.hash, hash.list
* Plugins: Added Math plugin, Bug fixes and enhancements to File,
- Image, URL and String plugins. Moved DBI, XML and GD plugins
+ Image, URL and String plugins. Moved DBI, XML and GD plugins
into separate distributions.
* Numerous other bug fixes, enhancements, documentation updates, all
@@ -152,7 +155,7 @@ See the documentation for further detail.
* embedded Perl can be optionally enabled (PERL/RAWPERL)
* full exception handling (TRY/THROW/CATCH/FINAL)
-
+
* user-defined macros (MACRO)
* definition of template metadata (META)
@@ -184,7 +187,7 @@ The Template Toolkit is provided with enough documentation to keep all
but the most voracious reader happy for quite some time.
The 'Changes' file in the distribution directory documents all visible
-changes between versions of the Template Toolkit. See the section
+changes between versions of the Template Toolkit. See the section
'VERSION COMPATABILITY' below for further details.
The 'TODO' file, also in the distribution directory, lists known bugs,
@@ -192,8 +195,8 @@ planned enhancements and possible new features for future versions.
The 'INSTALL' file covers the configuration and installation process.
-The rest of the documentation is distributed in Pod format. The Pod pages
-are installed when you 'make install' and can be viewed using 'perldoc',
+The rest of the documentation is distributed in Pod format. The Pod pages
+are installed when you 'make install' and can be viewed using 'perldoc',
e.g.
perldoc Template
@@ -241,12 +244,12 @@ these modules along with a brief description of their functions.
See the individual pages for further detail:
- perldoc Template::Context
- perldoc Template::Parser
+ perldoc Template::Context
+ perldoc Template::Parser
perldoc Template::Provider
If you're interested in the internals of the Template Toolkit and want
-to know more about how it all works, then you might like to have a look
+to know more about how it all works, then you might like to have a look
at the following:
perldoc Template::Manual::Internals
@@ -264,14 +267,14 @@ Further contributions welcome.
Most of the documentation is stable and reliable. Where it's not then
it's usually marked as such. In particular, the documentation for the
-internals (Template::Manual::Internals) and FAQ (Template::FAQ) are
+internals (Template::Manual::Internals) and FAQ (Template::FAQ) are
perpetually under construction.
SOURCE CODE
-----------
-The source code for the Template Toolkit is maintained in a public git
+The source code for the Template Toolkit is maintained in a public git
repository at github:
https://github.com/abw/Template2
@@ -296,13 +299,13 @@ are a number of knowledgeable and helpful individuals who frequent the
list (including the author) who can often offer help or suggestions.
Please respect their time and patience by checking the documentation
and/or mailing list archives before asking questions that may already
-have been answered.
+have been answered.
To subscribe to the mailing list, send an email to:
templates-request@template-toolkit.org
-with the message 'subscribe' in the body. You can also use the web
+with the message 'subscribe' in the body. You can also use the web
interface to subscribe or browse the archives:
http://mail.template-toolkit.org/mailman/listinfo/templates
@@ -318,7 +321,7 @@ for subscription and browsing the archives:
http://mail.template-toolkit.org/mailman/listinfo/templates-announce
-For information about commercial support and consultancy for the Template
+For information about commercial support and consultancy for the Template
Toolkit, please contact the author.
View
90 lib/Template.pm
@@ -3,7 +3,7 @@
# Template
#
# DESCRIPTION
-# Module implementing a simple, user-oriented front-end to the Template
+# Module implementing a simple, user-oriented front-end to the Template
# Toolkit.
#
# AUTHOR
@@ -26,13 +26,13 @@ use base 'Template::Base';
use Template::Config;
use Template::Constants;
-use Template::Provider;
+use Template::Provider;
use Template::Service;
use File::Basename;
use File::Path;
use Scalar::Util qw(blessed);
-our $VERSION = '2.23';
+our $VERSION = '2.24';
our $ERROR = '';
our $DEBUG = 0;
our $BINMODE = 0 unless defined $BINMODE;
@@ -45,9 +45,9 @@ Template::Config->preload() if $ENV{ MOD_PERL };
#------------------------------------------------------------------------
# process($input, \%replace, $output)
#
-# Main entry point for the Template Toolkit. The Template module
+# Main entry point for the Template Toolkit. The Template module
# delegates most of the processing effort to the underlying SERVICE
-# object, an instance of the Template::Service class.
+# object, an instance of the Template::Service class.
#------------------------------------------------------------------------
sub process {
@@ -58,24 +58,24 @@ sub process {
$options->{ binmode } = $BINMODE
unless defined $options->{ binmode };
-
- # we're using this for testing in t/output.t and t/filter.t so
+
+ # we're using this for testing in t/output.t and t/filter.t so
# don't remove it if you don't want tests to fail...
$self->DEBUG("set binmode\n") if $DEBUG && $options->{ binmode };
$output = $self->{ SERVICE }->process($template, $vars);
-
+
if (defined $output) {
$outstream ||= $self->{ OUTPUT };
unless (ref $outstream) {
my $outpath = $self->{ OUTPUT_PATH };
$outstream = "$outpath/$outstream" if $outpath;
- }
+ }
# send processed template to output stream, checking for error
return ($self->error($error))
if ($error = &_output($outstream, \$output, $options));
-
+
return 1;
}
else {
@@ -100,7 +100,7 @@ sub service {
#------------------------------------------------------------------------
# context()
#
-# Returns a reference to the the CONTEXT object withint the SERVICE
+# Returns a reference to the the CONTEXT object withint the SERVICE
# object.
#------------------------------------------------------------------------
@@ -128,7 +128,7 @@ sub _init {
my $debug = $config->{ DEBUG };
$config->{ DEBUG } = Template::Constants::debug_flags($self, $debug)
|| return if defined $debug && $debug !~ /^\d+$/;
-
+
# prepare a namespace handler for any CONSTANTS definition
if (my $constants = $config->{ CONSTANTS }) {
my $ns = $config->{ NAMESPACE } ||= { };
@@ -137,11 +137,11 @@ sub _init {
|| return $self->error(Template::Config->error);
$ns->{ $cns } = $constants;
}
-
+
$self->{ SERVICE } = $config->{ SERVICE }
|| Template::Config->service($config)
|| return $self->error(Template::Config->error);
-
+
$self->{ OUTPUT } = $config->{ OUTPUT } || \*STDOUT;
$self->{ OUTPUT_PATH } = $config->{ OUTPUT_PATH };
@@ -157,7 +157,7 @@ sub _output {
my ($where, $textref, $options) = @_;
my $reftype;
my $error = 0;
-
+
# call a CODE reference
if (($reftype = ref($where)) eq 'CODE') {
&$where($$textref);
@@ -165,7 +165,7 @@ sub _output {
# print to a glob (such as \*STDOUT)
elsif ($reftype eq 'GLOB') {
print $where $$textref;
- }
+ }
# append output to a SCALAR ref
elsif ($reftype eq 'SCALAR') {
$$where .= $$textref;
@@ -189,13 +189,13 @@ sub _output {
# strip file name and line number from error raised by die()
($error = $@) =~ s/ at \S+ line \d+\n?$//;
}
- elsif (open(FP, ">$where")) {
+ elsif (open(FP, ">$where")) {
# binmode option can be 1 or a specific layer, e.g. :utf8
my $bm = $options->{ binmode };
- if ($bm && $bm eq 1) {
+ if ($bm && $bm eq 1) {
binmode FP;
}
- elsif ($bm){
+ elsif ($bm){
binmode FP, $bm;
}
print FP $$textref;
@@ -222,22 +222,22 @@ __END__
Template - Front-end module to the Template Toolkit
-=head1 SYNOPSIS
+=head1 SYNOPSIS
use Template;
-
+
# some useful options (see below for full list)
my $config = {
INCLUDE_PATH => '/search/path', # or list ref
INTERPOLATE => 1, # expand "$var" in plain text
- POST_CHOMP => 1, # cleanup whitespace
+ POST_CHOMP => 1, # cleanup whitespace
PRE_PROCESS => 'header', # prefix each template
EVAL_PERL => 1, # evaluate Perl code blocks
};
-
+
# create Template object
my $template = Template->new($config);
-
+
# define template variables for replacement
my $vars = {
var1 => $value,
@@ -246,10 +246,10 @@ Template - Front-end module to the Template Toolkit
var4 => \&code,
var5 => $object,
};
-
+
# specify input filename, or file handle, text reference, etc.
my $input = 'myfile.html';
-
+
# process input template, substituting variables
$template->process($input, $vars)
|| die $template->error();
@@ -318,10 +318,10 @@ template variables.
# file handle (GLOB)
$tt->process(\*DATA)
|| die $tt->error(), "\n";
-
+
__END__
[% INCLUDE header %]
- This is a template defined in the __END__ section which is
+ This is a template defined in the __END__ section which is
accessible via the DATA "file handle".
[% INCLUDE footer %]
@@ -354,16 +354,16 @@ Examples:
my $output = '';
$tt->process('welcome.tt2', $vars, \$output)
|| die $tt->error(), "\n";
-
+
print "output: $output\n";
In an Apache/mod_perl handler:
sub handler {
my $req = shift;
-
+
# ...your code here...
-
+
# direct output to Apache::Request via $req->print($output)
$tt->process($file, $vars, $req) || do {
$req->log_reason($tt->error());
@@ -382,18 +382,18 @@ binary mode.
# either: hash reference of options
$tt->process($infile, $vars, $outfile, { binmode => 1 })
|| die $tt->error(), "\n";
-
+
# or: list of name, value pairs
$tt->process($infile, $vars, $outfile, binmode => 1)
|| die $tt->error(), "\n";
-Alternately, the C<binmode> argument can specify a particular IO layer such
+Alternately, the C<binmode> argument can specify a particular IO layer such
as C<:utf8>.
$tt->process($infile, $vars, $outfile, binmode => ':utf8')
|| die $tt->error(), "\n";
-The C<OUTPUT> configuration item can be used to specify a default output
+The C<OUTPUT> configuration item can be used to specify a default output
location other than C<\*STDOUT>. The C<OUTPUT_PATH> specifies a directory
which should be prefixed to all output locations specified as filenames.
@@ -402,11 +402,11 @@ which should be prefixed to all output locations specified as filenames.
OUTPUT_PATH => '/tmp',
...
}) || die Template->error(), "\n";
-
+
# use default OUTPUT (sub is called)
$tt->process('welcome.tt2', $vars)
|| die $tt->error(), "\n";
-
+
# write file to '/tmp/welcome.html'
$tt->process('welcome.tt2', $vars, 'welcome.html')
|| die $tt->error(), "\n";
@@ -439,7 +439,7 @@ L<Template::Exception> class. If the L<process()> method returns a false value
then the C<error()> method can be called to return an object of this class.
The L<type()|Template::Exception#type()> and
L<info()|Template::Exception#info()> methods can called on the object to
-retrieve the error type and information string, respectively. The
+retrieve the error type and information string, respectively. The
L<as_string()|Template::Exception#as_string()>
method can be called to return a string of the form C<$type - $info>. This
method is also overloaded onto the stringification operator allowing the
@@ -461,25 +461,25 @@ to that object.
=head2 context()
The L<Template::Service> module uses a core L<Template::Context> object for
-runtime processing of templates. This method returns a reference to
+runtime processing of templates. This method returns a reference to
that object and is equivalent to C<< $template-E<gt>service-E<gt>context() >>.
=head2 template($name)
This method is a simple wrapper around the L<Template::Context> method of the
-same name. It returns a compiled template for the source provided as an
+same name. It returns a compiled template for the source provided as an
argument.
=head1 CONFIGURATION SUMMARY
-The following list gives a short summary of each Template Toolkit
+The following list gives a short summary of each Template Toolkit
configuration option. See L<Template::Manual::Config> for full details.
=head2 Template Style and Parsing Options
=head3 START_TAG, END_TAG
-Define tokens that indicate start and end of directives
+Define tokens that indicate start and end of directives
(default: 'C<[%>' and 'C<%]>').
=head3 TAG_STYLE
@@ -531,7 +531,7 @@ Hash array pre-defining template blocks.
=head3 AUTO_RESET
-Enabled by default causing C<BLOCK> definitions to be reset each time a
+Enabled by default causing C<BLOCK> definitions to be reset each time a
template is processed. Disable to allow C<BLOCK> definitions to persist.
=head3 RECURSION
@@ -604,7 +604,7 @@ One or more base classes under which plugins may be found.
=head3 LOAD_PERL
-Flag to indicate regular Perl modules should be loaded if a named plugin
+Flag to indicate regular Perl modules should be loaded if a named plugin
can't be found (default: 0).
=head3 FILTERS
@@ -740,7 +740,7 @@ to use.
[% BLOCK hello %]
Hello World
[% END %]
-
+
[% INCLUDE hello %]
=head2 FOREACH
@@ -754,7 +754,7 @@ Repeat the enclosed C<FOREACH> ... C<END> block for each value in the list.
=head2 WHILE
-The block enclosed between C<WHILE> and C<END> block is processed while
+The block enclosed between C<WHILE> and C<END> block is processed while
the specified condition is true.
[% WHILE condition %]
Please sign in to comment.
Something went wrong with that request. Please try again.