# Mojolicious::Plugin::TtRenderer [](http://travis-ci.org/plicease/Mojolicious-Plugin-TtRenderer) Template Renderer Plugin for Mojolicious # SYNOPSIS [Mojolicious::Lite](https://metacpan.org/pod/Mojolicious::Lite): plugin 'tt_renderer'; [Mojolicious](https://metacpan.org/pod/Mojolicious) $self->plugin('tt_renderer'); # DESCRIPTION This plugin is a simple Template Toolkit renderer for [Mojolicious](https://metacpan.org/pod/Mojolicious). Its defaults are usually reasonable, although for finer grain detail in configuration you may want to use [Mojolicious::Plugin::TtRenderer::Engine](https://metacpan.org/pod/Mojolicious::Plugin::TtRenderer::Engine) directly. # OPTIONS These are the options that can be passed in as arguments to this plugin. ## template\_options Configuration hash passed into [Template](https://metacpan.org/pod/Template)'s constructor, see [Template Toolkit's configuration summary](https://metacpan.org/pod/Template#CONFIGURATION-SUMMARY) for details. Here is an example using the [Mojolicious::Lite](https://metacpan.org/pod/Mojolicious::Lite) form: plugin 'tt_renderer' => { template_options => { PRE_CHOMP => 1, POST_CHOMP => 1, TRIM => 1, }, }; Here is the same example using the full [Mojolicious](https://metacpan.org/pod/Mojolicious) app form: package MyApp; use Mojo::Base qw( Mojolicious ); sub startup { my($self) = @_; $self->plugin('tt_renderer' => { template_options => { PRE_CHOMP => 1, POST_CHOMP => 1, TRIM => 1, }, } ... } These options will be used if you do not override them: - INCLUDE\_PATH Generated based on your application's renderer's configuration. It will include all renderer paths, in addition to search files located in the `__DATA__` section by the usual logic used by [Mojolicious](https://metacpan.org/pod/Mojolicious). - COMPILE\_EXT `.ttc` - UNICODE `1` (true) - ENCODING `utf-87` - CACHE\_SIZE `128` - RELATIVE `1` (true) ## cache\_dir Specifies the directory in which compiled template files are written. This: plugin 'tt_renderer', { cache_dir => 'some/path' }; is equivalent to plugin 'tt_renderer', { template_options { COMPILE_DIR => 'some/path' } }; except in the first example relative paths are relative to the [Mojolicious](https://metacpan.org/pod/Mojolicious) app's home directory (`$app->home`). # STASH ## h Helpers are available via the `h` entry in the stash. go back to index ## c The current controller instance can be accessed as `c`. I see you are requesting a document from [% c.req.headers.host %]. # EXAMPLES [Mojolicious::Lite](https://metacpan.org/pod/Mojolicious::Lite) example: use Mojolicious::Lite; plugin 'tt_renderer'; get '/' => sub { my $self = shift; $self->render('index'); }; app->start; __DATA__ @@ index.html.tt [% WRAPPER 'layouts/default.html.tt' title = 'Welcome' %]
Welcome to the Mojolicious real-time web framework!
Welcome to the TtRenderer plugin!
[% END %] @@ layouts/default.html.tt