{
    "mode": "perldoc",
    "parameter": "Template::Modules",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AModules/json",
    "generated": "2026-06-12T13:10:32Z",
    "sections": {
        "NAME": {
            "content": "Template::Modules - Template Toolkit Modules\n",
            "subsections": []
        },
        "Template Toolkit Modules": {
            "content": "This documentation provides an overview of the different modules that comprise the Template\nToolkit.\n",
            "subsections": [
                {
                    "name": "Template",
                    "content": "The Template module is the front-end to the Template Toolkit for Perl programmers.\n\nuse Template;\nmy $tt = Template->new();\n$tt->process('hello.html', message => 'Hello World');\n"
                },
                {
                    "name": "Template::Base",
                    "content": "The Template::Base module implements a base class from which the other Template Toolkit modules\nare derived. It implements common functionality for creating objects, error reporting,\ndebugging, and so on.\n"
                },
                {
                    "name": "Template::Config",
                    "content": "The Template::Config module defines the configuration of the Template Toolkit for your system.\nIt is an example of a *factory module* which is responsible for instantiating the various other\nmodules used in the Template Toolkit.\n\nFor example, the Template::Config module defines the $STASH package variable which indicates\nwhich version of the Template::Stash you are using by default. If you elected to use the faster\nXS stash when you installed the Template Toolkit, then this will be set as:\n\n$STASH = 'Template::Stash::XS';\n\nOtherwise you'll get the regular Perl stash:\n\n$STASH = 'Template::Stash';\n\nThis approach means that other parts of the Template Toolkit don't have to worry about which\nstash you're using. They just ask the Template::Config module to create a stash of the right\nkind.\n"
                },
                {
                    "name": "Template::Constants",
                    "content": "The Template::Constants defines a number of constants that are used by the Template Toolkit.\n\nFor example, the \":chomp\" tagset defines the \"CHOMP???\" constants that can be used with the\n\"PRECHOMP\" and \"POSTCHOMP\" configuration options.\n\nuse Template::Constants ':chomp';\nmy $tt = Template->new({\nPRECHOMP => CHOMPCOLLAPSE,\n});\n"
                },
                {
                    "name": "Template::Context",
                    "content": "The Template::Context module defines a runtime context in which templates are processed. A\ncontext keeps track of all the templates, variables, plugins, and other resources that are\navailable (either directly or through delegate objects) and provides methods to fetch, store,\nand perform various operations on them.\n"
                },
                {
                    "name": "Template::Document",
                    "content": "The Template::Document module implements a compiled template document object. This is generated\nby the Template::Parser module.\n"
                },
                {
                    "name": "Template::Exception",
                    "content": "The Template::Exception module implements an exception object which is used for runtime error\nreporting.\n"
                },
                {
                    "name": "Template::Filters",
                    "content": "The Template::Filters module implements a filter provider. It includes the core collection of\nfilters that can be used via the \"FILTER\" directive.\n"
                },
                {
                    "name": "Template::Iterator",
                    "content": "The Template::Iterator module implements a data iterator which steps through each item in a list\nin turn. It is used by the \"FOREACH\" directive. Within a \"FOREACH\" block, the \"loop\" variable\nalways references the current iterator object.\n\n[%  FOREACH item IN list;\nIF loop.first;\n# first item in loop\nELSIF loop.last;\n# last item in loop\nELSE;\n# any other item in loop\nEND;\nEND\n%]\n"
                },
                {
                    "name": "Template::Namespace::Constants",
                    "content": "The Template::Namespace::Constants module is used internally to represent constants. These can\nbe resolved immediately at the point that a template is compiled.\n"
                },
                {
                    "name": "Template::Parser",
                    "content": "The Template::Parser module is used to parse a source template and turn it into Perl code which\ncan be executed.\n"
                },
                {
                    "name": "Template::Plugin",
                    "content": "The Template::Plugin module is a base class for Template Toolkit plugins that can be loaded on\ndemand from within a template using the \"USE\" directive.\n"
                },
                {
                    "name": "Template::Plugins",
                    "content": "The Template::Plugins module is the plugins provider. It loads and prepares plugins as and when\nthey are requested from within a template.\n"
                },
                {
                    "name": "Template::Provider",
                    "content": "The Template::Provider module is responsible for loading, compiling and caching templates.\n"
                },
                {
                    "name": "Template::Service",
                    "content": "The Template::Service module implements a service layer that sits just behind the Template\nmodule, and just in front of a Template::Context. It handles each request to process a template\n(forwarded from the Template module). It adds any headers and/or footers (specified via the\n\"PREPROCESS\" and \"POSTPROCESS\" options), applies any wrapper (the \"WRAPPER\" option) and\ncatches any errors returned (the \"ERRORS\" option).\n"
                },
                {
                    "name": "Template::Stash",
                    "content": "The Template::Stash module is used to fetch and store template variables. It implements all of\nthe magic associated with the dot operator.\n"
                },
                {
                    "name": "Template::Stash::XS",
                    "content": "The Template::Stash::XS module is a high-speed implementation of Template::Stash written in C.\n"
                },
                {
                    "name": "Template::Test",
                    "content": "The Template::Test module is used to automate the Template Toolkit test scripts.\n"
                }
            ]
        }
    },
    "summary": "Template::Modules - Template Toolkit Modules",
    "flags": [],
    "examples": [],
    "see_also": []
}