NAME

Plack::App::TemplateToolkit - Basic Template Toolkit

SYNOPSIS

# in app.psgi
use Plack::Builder;
use Plack::App::TemplateToolkit;

my $root = '/path/to/htdocs/';

my $tt_app = Plack::App::TemplateToolkit->new(
    root => $root,    # Required
)->to_app();

return builder {

    # Page to show when requested file is missing
    enable "Plack::Middleware::ErrorDocument",
        404 => "$root/page_not_found.html";

    # These files can be served directly
    enable "Plack::Middleware::Static",
        path => qr{[gif|png|jpg|swf|ico|mov|mp3|pdf|js|css]$},
        root => $root;

    # Our application
    $tt_app;
}

DESCRIPTION

Plack::App::TemplateToolkit - process files through Template Toolkit (TT)

The idea behind this module is to provide access to Template Toolkit (TT) for content that is ALMOST static, but where having the power of TT can make the content easier to manage. You probably only want to use this for the simpliest of sites, but it should be easy enough to migrate to something more significant later.

The QUERY_STRING params are available to the templates, but the more you use these the harder it could be to migrate later so you might want to look at a propper framework such as Catalyst if you do want to use them:

[% params.get('field') %] params is a L<Hash::MultiValue>

You can mix this application with other Plack::App applications which you will find on CPAN.

CONFIGURATIONS

root

Required, root where templates live, e.g. docroot, this can be an array reference or a string.

extension

Limit to only files with this extension.

content_type

Specify the Content-Type header you want returned, defaults to text/html

dir_index

Which file to use as a directory index, defaults to index.html

eval_perl

False by default, this option lets you run perl blocks in your templates - I would strongly recommend NOT using this.

REPO

https://github.com/ranguard/Plack-App-TemplateToolkit/

AUTHOR

Leo Lapworth

SEE ALSO

Plack