Template::Stash::XS(3pm) User Contributed Perl Documentation Template::Stash::XS(3pm)NAME
Template::Stash::XS - High-speed variable stash written in C
SYNOPSIS
use Template;
use Template::Stash::XS;
my $stash = Template::Stash::XS->new(\%vars);
my $tt2 = Template->new({ STASH => $stash });
DESCRIPTION
The Template:Stash::XS module is an implementation of the Template::Stash written in C. The "XS" in the name refers to Perl's XS extension
system for interfacing Perl to C code. It works just like the regular Perl implementation of Template::Stash but runs about twice as fast.
The easiest way to use the XS stash is to configure the Template Toolkit to use it by default. You can do this at installation time (when
you run "perl Makefile.PL") by answering 'y' to the questions:
Do you want to build the XS Stash module? y
Do you want to use the XS Stash by default? y
See the INSTALL file distributed with the Template Toolkit for further details on installation.
If you don't elect to use the XS stash by default then you should use the "STASH" configuration item when you create a new Template object.
This should reference an XS stash object that you have created manually.
use Template;
use Template::Stash::XS;
my $stash = Template::Stash::XS->new(\%vars);
my $tt2 = Template->new({ STASH => $stash });
Alternately, you can set the $Template::Config::STASH package variable like so:
use Template;
use Template::Config;
$Template::Config::STASH = 'Template::Stash::XS';
my $tt2 = Template->new();
The XS stash will then be automatically used.
If you want to use the XS stash by default and don't want to re-install the Template Toolkit, then you can manually modify the
"Template/Config.pm" module near line 42 to read:
$STASH = 'Template::Stash::XS';
BUGS
Please report bugs to the Template Toolkit mailing list templates@template-toolkit.org
AUTHORS
Andy Wardley <abw@wardley.org> <http://wardley.org/>
Doug Steinwand <dsteinwand@citysearch.com>
COPYRIGHT
Copyright (C) 1996-2012 Andy Wardley. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Template::Stash
perl v5.14.2 2012-01-13 Template::Stash::XS(3pm)
Check Out this Related Man Page
Template::Modules(3) User Contributed Perl Documentation Template::Modules(3)NAME
Template::Modules - Template Toolkit Modules
Template Toolkit Modules
This documentation provides an overview of the different modules that comprise the Template Toolkit.
Template
The Template module is the front-end to the Template Toolkit for Perl programmers.
use Template;
my $tt = Template->new();
$tt->process('hello.html', message => 'Hello World');
Template::Base
The Template::Base module implements a base class from which the other Template Toolkit modules are derived. It implements common
functionality for creating objects, error reporting, debugging, and so on.
Template::Config
The Template::Config module defines the configuration of the Template Toolkit for your system. It is an example of a factory module which
is responsible for instantiating the various other modules used in the Template Toolkit.
For example, the Template::Config module defines the $STASH package variable which indicates which version of the Template::Stash you are
using by default. If you elected to use the faster XS stash when you installed the Template Toolkit, then this will be set as:
$STASH = 'Template::Stash::XS';
Otherwise you'll get the regular Perl stash:
$STASH = 'Template::Stash';
This approach means that other parts of the Template Toolkit don't have to worry about which stash you're using. They just ask the
Template::Config module to create a stash of the right kind.
Template::Constants
The Template::Constants defines a number of constants that are used by the Template Toolkit.
For example, the ":chomp" tagset defines the "CHOMP_???" constants that can be used with the "PRE_CHOMP" and "POST_CHOMP" configuration
options.
use Template::Constants ':chomp';
my $tt = Template->new({
PRE_CHOMP => CHOMP_COLLAPSE,
});
Template::Context
The Template::Context module defines a runtime context in which templates are processed. A context keeps track of all the templates,
variables, plugins, and other resources that are available (either directly or through delegate objects) and provides methods to fetch,
store, and perform various operations on them.
Template::Document
The Template::Document module implements a compiled template document object. This is generated by the Template::Parser module.
Template::Exception
The Template::Exception module implements an exception object which is used for runtime error reporting.
Template::Filters
The Template::Filters module implements a filter provider. It includes the core collection of filters that can be used via the "FILTER"
directive.
Template::Iterator
The Template::Iterator module implements a data iterator which steps through each item in a list in turn. It is used by the "FOREACH"
directive. Within a "FOREACH" block, the "loop" variable always references the current iterator object.
[% FOREACH item IN list;
IF loop.first;
# first item in loop
ELSIF loop.last;
# last item in loop
ELSE;
# any other item in loop
END;
END
%]
Template::Namespace::Constants
The Template::Namespace::Constants module is used internally to represent constants. These can be resolved immediately at the point that a
template is compiled.
Template::Parser
The Template::Parser module is used to parse a source template and turn it into Perl code which can be executed.
Template::Plugin
The Template::Plugin module is a base class for Template Toolkit plugins that can be loaded on demand from within a template using the
"USE" directive.
Template::Plugins
The Template::Plugins module is the plugins provider. It loads and prepares plugins as and when they are requested from within a template.
Template::Provider
The Template::Provider module is responsible for loading, compiling and caching templates.
Template::Service
The Template::Service module implements a service layer that sits just behind the Template module, and just in front of a
Template::Context. It handles each request to process a template (forwarded from the Template module). It adds any headers and/or footers
(specified via the "PRE_PROCESS" and "POST_PROCESS" options), applies any wrapper (the "WRAPPER" option) and catches any errors returned
(the "ERRORS" option).
Template::Stash
The Template::Stash module is used to fetch and store template variables. It implements all of the magic associated with the dot operator.
Template::Stash::XS
The Template::Stash::XS module is a high-speed implementation of Template::Stash written in C.
Template::Test
The Template::Test module is used to automate the Template Toolkit test scripts.
perl v5.16.3 2011-12-20 Template::Modules(3)