NAME
Plack::Middleware::TMT - Text::MicroTemplate on the Plack
SYNOPSIS
enable 'TMT',
include_path => 'tmpl';
support few options
enable 'TMT',
include_path => 'tmpl',
tmpl_extension => '.mt',
pass_through => 1,
macro => +{
hello => sub { 'hello!' },
};
DESCRIPTION
when you write tiny web app, you want to write some perl codes in template files. it sounds evil. you can use this module for test or micro app with yourself.
for example index.psgi
use strict;
use warnings;
use Plack::Builder;
builder {
mount '/' => builder {
enable 'TMT',
include_path => '/path/to/tmpl/dir',
tmpl_extension => '.mt';
};
};
and /path/to/tmpl/dir/index.mt like below
? my $r = shift; # Plack::Request Obj
<pre>
<?= d($r) ?>
</pre>
`d` is reserved macro. it works as dumper function.
then you can plackup
$ plackup index.psgi
finally, you can browse http://localhost:5000/
METHOD
- call
- prepare_app
- process_template
REPOSITORY
Plack::Middleware::TMT is hosted on github <http://github.com/bayashi/Plack-Middleware-TMT>
AUTHOR
Dai Okabayashi <bayashi@cpan.org>
SEE ALSO
Text::MicroTemplate::File, Text::MicroTemplate
LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.