View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Yanick Champoux > Dancer-1.3126 > Dancer::Template::TemplateToolkit



Annotate this POD


View/Report Bugs
Source   Latest Release: Dancer-1.3400


Dancer::Template::TemplateToolkit - Template Toolkit wrapper for Dancer


This class is an interface between Dancer's template engine abstraction layer and the Template module.

This template engine is recommended for production purposes, but depends on the Template module.

In order to use this engine, use the template setting:

    template: template_toolkit

This can be done in your config.yml file or directly in your app code with the set keyword.

Note that by default, Dancer configures the Template::Toolkit engine to use <% %> brackets instead of its default [% %] brackets. This can be changed within your config file - for example:

    template: template_toolkit
            start_tag: '[%'
            stop_tag: '%]'

You can also add any options you would normally add to the Template module's initialization. You could, for instance, enable saving the compiled templates:

            COMPILE_DIR: 'caches/templates'
            COMPILE_EXT: '.ttc'

Note though that unless you change them, Dancer sets both of the Template options ANYCASE and ABSOLUTE on, as well as pointing INCLUDE_PATH to your views directory and setting ENCODING to your charset setting.


By default, Template is used, but you can configure Dancer to use a subclass of Template with the subclass option.

            subclass: My::Template

When used like this, Dancer skips the defaults mentioned above. Only those included in your config file are sent to the subclass.

WRAPPER, META variables, SETs ^

Dancer already provides a WRAPPER-like ability, which we call a "layout". The reason we do not use TT's WRAPPER (which also makes it incompatible with it) is because not all template systems support it. Actually, most don't.

However, you might want to use it, and be able to define META variables and regular Template::Toolkit variables.

These few steps will get you there:

Done! Everything will work fine out of the box, including variables and META variables.


Dancer, Template


This module has been written by Alexis Sukrieh


This module is free software and is released under the same terms as Perl itself.

syntax highlighting: