From bf71ca8cec3bba9fcf59017aaf1c0d723234c296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Mon, 10 Nov 2008 11:13:50 -0800 Subject: [PATCH] Accept options for the Template object Prepare 0.02 --- Changes | 3 ++- lib/MojoX/Renderer/TT.pm | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index 2f6ee20..1e5ba84 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for MojoX-Renderer-TT -0.02 +0.02 November 10, 2008 + - Add template_options parameter - Fix Template dependency 0.01 November 9, 2008 diff --git a/lib/MojoX/Renderer/TT.pm b/lib/MojoX/Renderer/TT.pm index a99c382..8f8aae5 100644 --- a/lib/MojoX/Renderer/TT.pm +++ b/lib/MojoX/Renderer/TT.pm @@ -34,6 +34,7 @@ sub _init { CACHE_SIZE => 128, RELATIVE => 1, ABSOLUTE => 1, + %{$args{template_options} || {}}, ); $self->tt(Template->new(\%config)) @@ -64,13 +65,9 @@ sub _render { MojoX::Renderer::TT - Template Toolkit renderer for Mojo -=head1 VERSION - -Version 0.01 - =cut -our $VERSION = '0.01'; +our $VERSION = '0.02'; =head1 SYNOPSIS @@ -81,7 +78,16 @@ Add the handler: sub startup { ... - $self->renderer->add_handler( tt => MojoX::Renderer::TT->new( mojo => $self ) ); + + my $tt = MojoX::Renderer::TT->new( + mojo => $self, + template_options => + { PROCESS => 'tpl/wrapper', + FILTERS => [ foo => [ \&filter_factory, 1] + } + ); + + $self->renderer->add_handler( html => $tt ); } And then in the handler call render which will call the @@ -94,8 +100,22 @@ MojoX::Renderer::TT renderer. =head2 new -This currently requires a C parameter pointing to the base class (Mojo). -object. This method returns not a TT object, but a handler for the Mojo renderer. +This method returns not a TT object, but a handler for the Mojo renderer. + +Supported parameters are + +=over 4 + +=item mojo +C currently requires a C parameter pointing to the base class (Mojo). +object. + +=item template_options + +A hash reference of options that are passed to Template->new(). + +=back + =head1 AUTHOR @@ -108,8 +128,7 @@ Ask Bjørn Hansen, C<< >> * Don't require the mojo parameter * Move the default template cache directory? * Should the "tx" tpl parameter be called "c" (for context) instead? - * Accept options for setting up the Tempate object - * Better way to pass parameters to the templates? + * Better way to pass parameters to the templates? (stash) * More sophisticated default search path? =head1 BUGS