NAME
Plack::App::TemplateToolkit
VERSION
version 0.05
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 and Plack::Middleware 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
- pre_process
-
Optional, supply a file to pre process before serving each html file (see
Template
configuration PRE_PROCESS) - process
-
Optional, supply a file to process (see
Template
configuration PROCESS) - eval_perl
-
Default to 0, this option lets you run perl blocks in your templates - I would strongly recommend NOT using this. (see
Template
configuration EVAL_PERL) - interpolate
-
Default to 0, see
Template
configuration INTERPOLATE - post_chomp
-
Defaults to 1, see
Template
configuration POST_CHOMP
SEE ALSO
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.