NAME

Apache2::WebApp::Template - Interface to the Template Toolkit

SYNOPSIS

$c->template->method( ... );

DESCRIPTION

A persistent template object that provides methods of the Template Toolkit that are accessible from within your web application using %controller. Template options can be easily configured in your project webapp.conf

EXAMPLES

Template processing

CONFIG

[template]
cache_size   = 100                               # total files to store in cache
compile_dir  = /path/to/project/tmp/template     # path to template cache
include_path = /path/to/project/template         # path to template directory
stat_ttl     = 60                                # template to HTML build time (in seconds)

METHOD

sub _default {
    my ( $self, $c ) @_;

    $c->request->content_type('text/html');

    $c->template->process(
        'file.tt', {
            foo => 'bar',
            baz => qw( bucket1 bucket2 bucket3 ),
            qux => qw{
                       key1 => 'value1',
                       key2 => 'value2',
                        ...
                   },
            ...
        }
      )
      or $self->_error( $c, 'Template process failed', $c->template->error() );

    exit;
}

TEMPLATE

[% foo %]

[% FOREACH bucket = bar %]
    [% bucket %]
[% END %]

[% qux.key1 %]
[% qux.key2 %]

SEE ALSO

Apache2::WebApp, Template::Manual::Syntax, Template::Manual::Directives, Template::Manual::Variables, Template::Manual::Filters, Template::Manual::VMethods

AUTHOR

Marc S. Brooks, <mbrooks@cpan.org> http://mbrooks.info

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html