Plack::Middleware::TMT - Text::MicroTemplate on the Plack
enable 'TMT', include_path => 'tmpl';
support few options
enable 'TMT', include_path => 'tmpl', tmpl_extension => '.mt', pass_through => 1, macro => +{ hello => sub { 'hello!' }, };
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/
Plack::Middleware::TMT is hosted on github <http://github.com/bayashi/Plack-Middleware-TMT>
Dai Okabayashi <bayashi@cpan.org>
Text::MicroTemplate::File, Text::MicroTemplate
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Plack::Middleware::TMT, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::TMT
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::TMT
For more information on module installation, please visit the detailed CPAN module installation guide.