NAME

Plack::App::TemplateToolkit

VERSION

version 0.04

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.

NAME

Plack::App::TemplateToolkit - Basic Plack App Template Toolkit

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.

pre_process

Optional, supply a file to pre process before serving each html file (passed to Template as PRE_PROCESS)

SEE ALSO

Plack, Template

AUTHOR

Leo Lapworth <LLAP@cuckoo.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Leo Lapworth.

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