diff --git a/Changes b/Changes index 4553473..9044816 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Mojolicious::Plugin::TtRenderer {{$NEXT}} + - Documentation updates. 1.38 January 27, 2013 - fixed but where DATA templates were not being rendered with empty renderer path diff --git a/README.pod b/README.pod index 00b4003..d6810bc 100644 --- a/README.pod +++ b/README.pod @@ -6,13 +6,13 @@ Mojolicious::Plugin::TtRenderer - Template Renderer Plugin =head1 SYNOPSIS - # Mojolicious - $self->plugin('tt_renderer'); - $self->plugin(tt_renderer => {template_options => {FILTERS => [ ... ]}}); + # Mojolicious + $self->plugin('tt_renderer'); + $self->plugin(tt_renderer => {template_options => {FILTERS => [ ... ]}}); - # Mojolicious::Lite - plugin 'tt_renderer'; - plugin tt_renderer => {template_options => {FILTERS => [ ... ]}}; + # Mojolicious::Lite + plugin 'tt_renderer'; + plugin tt_renderer => {template_options => {FILTERS => [ ... ]}}; =head1 DESCRIPTION @@ -26,7 +26,7 @@ L and implements the following new ones. =head2 C - $plugin->register; + $plugin->register; Register renderer in L application. @@ -34,11 +34,14 @@ Register renderer in L application. The current controller instance can be accessed as C. - [% c.req.headers.host %] + [% c.req.headers.host %] =head1 SEE ALSO -L, L, L, L. +L, +L, +L, +L. =head1 AUTHOR @@ -55,7 +58,7 @@ L. You can find documentation for this module with the perldoc command. - perldoc Mojolicious::Plugin::TtRenderer + perldoc Mojolicious::Plugin::TtRenderer You can also look for information at: diff --git a/lib/Mojolicious/Plugin/TtRenderer.pm b/lib/Mojolicious/Plugin/TtRenderer.pm index 1876345..79e40f5 100644 --- a/lib/Mojolicious/Plugin/TtRenderer.pm +++ b/lib/Mojolicious/Plugin/TtRenderer.pm @@ -32,13 +32,13 @@ Mojolicious::Plugin::TtRenderer - Template Renderer Plugin =head1 SYNOPSIS - # Mojolicious - $self->plugin('tt_renderer'); - $self->plugin(tt_renderer => {template_options => {FILTERS => [ ... ]}}); + # Mojolicious + $self->plugin('tt_renderer'); + $self->plugin(tt_renderer => {template_options => {FILTERS => [ ... ]}}); - # Mojolicious::Lite - plugin 'tt_renderer'; - plugin tt_renderer => {template_options => {FILTERS => [ ... ]}}; + # Mojolicious::Lite + plugin 'tt_renderer'; + plugin tt_renderer => {template_options => {FILTERS => [ ... ]}}; =head1 DESCRIPTION @@ -52,7 +52,7 @@ L and implements the following new ones. =head2 C - $plugin->register; + $plugin->register; Register renderer in L application. @@ -60,11 +60,14 @@ Register renderer in L application. The current controller instance can be accessed as C. - [% c.req.headers.host %] + [% c.req.headers.host %] =head1 SEE ALSO -L, L, L, L. +L, +L, +L, +L. =head1 AUTHOR @@ -81,7 +84,7 @@ L. You can find documentation for this module with the perldoc command. - perldoc Mojolicious::Plugin::TtRenderer + perldoc Mojolicious::Plugin::TtRenderer You can also look for information at: diff --git a/lib/Mojolicious/Plugin/TtRenderer/Engine.pm b/lib/Mojolicious/Plugin/TtRenderer/Engine.pm index ce10fe2..3819816 100644 --- a/lib/Mojolicious/Plugin/TtRenderer/Engine.pm +++ b/lib/Mojolicious/Plugin/TtRenderer/Engine.pm @@ -227,27 +227,27 @@ Mojolicious::Plugin::TtRenderer::Engine - Template Toolkit renderer for Mojo Add the handler: - sub startup { - ... + sub startup { + ... + + # Via mojolicious plugin + $self->plugin(tt_renderer => {template_options => {FILTERS => [ ... ]}}); + + # Or manually + use Mojolicious::Plugin::TtRenderer::Engine; + + my $tt = Mojolicious::Plugin::TtRenderer::Engine->build( + mojo => $self, + template_options => { + PROCESS => 'tpl/wrapper', + FILTERS => [ ... ], + UNICODE => 1, + ENCODING => 'UTF-8', + } + ); - # Via mojolicious plugin - $self->plugin(tt_renderer => {template_options => {FILTERS => [ ... ]}}); - - # Or manually - use Mojolicious::Plugin::TtRenderer::Engine; - - my $tt = Mojolicious::Plugin::TtRenderer::Engine->build( - mojo => $self, - template_options => { - PROCESS => 'tpl/wrapper', - FILTERS => [ ... ], - UNICODE => 1, - ENCODING => 'UTF-8', - } - ); - - $self->renderer->add_handler( tt => $tt ); - } + $self->renderer->add_handler( tt => $tt ); + } Template parameter are taken from C< $c->stash >. @@ -257,20 +257,20 @@ The template file for C<"example/welcome"> would be C<"templates/welcome.html.tt When template file is not available rendering from C<__DATA__> is attempted. - __DATA__ + __DATA__ - @@ welcome.html.tt - Welcome, [% user.name %]! + @@ welcome.html.tt + Welcome, [% user.name %]! Inline template is also supported: - $self->render(inline => '[% 1 + 1 %]', handler => 'tt'); + $self->render(inline => '[% 1 + 1 %]', handler => 'tt'); =head1 HELPERS Helpers are exported automatically under C namespace. - [% h.url_for('index') %] + [% h.url_for('index') %] =head1 METHODS @@ -288,7 +288,11 @@ object. When used the INCLUDE_PATH will be set to =item template_options -A hash reference of options that are passed to Template->new(). +A hash reference of options that are passed to Template->new(). Note that if you +specify an C through this option it will remove the DATA section +templates from your path. A better way to specify an C if you also +want to use DATA section templates it by manipulting the L +path. =item cache_dir @@ -297,18 +301,19 @@ templates. Will default to a temp-dir if not set. =back +=head1 SEE ALSO + +L, +L, +L, +L. + =head1 AUTHOR Current maintainer: Graham Ollis C<< >> Original author: Ask Bjørn Hansen, C<< >> -=head1 TODO - - * Better support non-Mojolicious frameworks - * Better way to pass parameters to the templates? (stash) - * More sophisticated default search path? - =head1 BUGS Please report any bugs or feature requests to the project's github issue tracker @@ -318,7 +323,7 @@ L. You can find documentation for this module with the perldoc command. - perldoc Mojolicious::Plugin::TtRenderer::Engine + perldoc Mojolicious::Plugin::TtRenderer::Engine You can also look for information at: