# perldoc > Template::Modules

## NAME
    [Template::Modules](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AModules/markdown) - 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](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3ABase/markdown)
    The [Template::Base](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3ABase/markdown) 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](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AConfig/markdown)
    The [Template::Config](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AConfig/markdown) 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](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AConfig/markdown) module defines the $STASH package variable which indicates
    which version of the [Template::Stash](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AStash/markdown) 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](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AStash%3A%3AXS/markdown)';

    Otherwise you'll get the regular Perl stash:

        $STASH = '[Template::Stash](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AStash/markdown)';

    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](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AConfig/markdown) module to create a stash of the right
    kind.

### [Template::Constants](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AConstants/markdown)
    The [Template::Constants](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AConstants/markdown) 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](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AConstants/markdown) ':chomp';
        my $tt = Template->new({
            PRE_CHOMP => CHOMP_COLLAPSE,
        });

### [Template::Context](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AContext/markdown)
    The [Template::Context](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AContext/markdown) 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](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3ADocument/markdown)
    The [Template::Document](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3ADocument/markdown) module implements a compiled template document object. This is generated
    by the [Template::Parser](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AParser/markdown) module.

### [Template::Exception](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AException/markdown)
    The [Template::Exception](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AException/markdown) module implements an exception object which is used for runtime error
    reporting.

### [Template::Filters](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AFilters/markdown)
    The [Template::Filters](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AFilters/markdown) module implements a filter provider. It includes the core collection of
    filters that can be used via the "FILTER" directive.

### [Template::Iterator](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AIterator/markdown)
    The [Template::Iterator](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AIterator/markdown) 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](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3ANamespace%3A%3AConstants/markdown)
    The [Template::Namespace::Constants](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3ANamespace%3A%3AConstants/markdown) module is used internally to represent constants. These can
    be resolved immediately at the point that a template is compiled.

### [Template::Parser](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AParser/markdown)
    The [Template::Parser](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AParser/markdown) module is used to parse a source template and turn it into Perl code which
    can be executed.

### [Template::Plugin](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3APlugin/markdown)
    The [Template::Plugin](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3APlugin/markdown) 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](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3APlugins/markdown)
    The [Template::Plugins](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3APlugins/markdown) module is the plugins provider. It loads and prepares plugins as and when
    they are requested from within a template.

### [Template::Provider](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AProvider/markdown)
    The [Template::Provider](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AProvider/markdown) module is responsible for loading, compiling and caching templates.

### [Template::Service](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AService/markdown)
    The [Template::Service](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AService/markdown) module implements a service layer that sits just behind the Template
    module, and just in front of a [Template::Context](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AContext/markdown). 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](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AStash/markdown)
    The [Template::Stash](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AStash/markdown) module is used to fetch and store template variables. It implements all of
    the magic associated with the dot operator.

### [Template::Stash::XS](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AStash%3A%3AXS/markdown)
    The [Template::Stash::XS](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AStash%3A%3AXS/markdown) module is a high-speed implementation of [Template::Stash](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AStash/markdown) written in C.

### [Template::Test](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3ATest/markdown)
    The [Template::Test](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3ATest/markdown) module is used to automate the Template Toolkit test scripts.

