Skip Menu |
 

This queue is for tickets about the Catalyst-View-TT CPAN distribution.

Report information
The Basics
Id: 61710
Status: resolved
Priority: 0/
Queue: Catalyst-View-TT

People
Owner: Nobody in particular
Requestors: DATA [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.35
Fixed in: (no value)



Subject: Ability to load other classes beside Template.pm
Download (untitled) / with headers
text/plain 328b
The problem i'm trying to solve is, that i want to get Catalyst::View::TT to use Template::HTML because i'm tired of writing [% foo | html %] [% bar | html %] [% baz | html %] all the time. The attached patch introduces a new configuration variable called TEMPLATE_CLASS which one can set to "Template::HTML" for example.
Subject: template_class.diff
Download template_class.diff
text/x-diff 1.3k
Index: lib/Catalyst/View/TT.pm =================================================================== --- lib/Catalyst/View/TT.pm (revision 13602) +++ lib/Catalyst/View/TT.pm (working copy) @@ -186,8 +186,13 @@ } } + my $template_class = delete $config->{TEMPLATE_CLASS} || "Template"; + unless(eval "require $template_class; 1") { + die("Failed to load $template_class: $@"); + } + $self->{template} = - Template->new($config) || do { + $template_class->new($config) || do { my $error = Template->error(); $c->log->error($error); $c->error($error); @@ -631,7 +636,7 @@ =head2 C<TEMPLATE_EXTENSION> -a sufix to add when looking for templates bases on the C<match> method in L<Catalyst::Request>. +a suffix to add when looking for templates bases on the C<match> method in L<Catalyst::Request>. For example: @@ -641,6 +646,11 @@ Would by default look for a template in <root>/test/test. If you set TEMPLATE_EXTENSION to '.tt', it will look for <root>/test/test.tt. +=head2 C<TEMPLATE_CLASS> + +The class to load instead of L<Template>. L<Template::HTML> is a valid value +for example. Useful if you wan't to use modules derived from Template.pm. + =head2 C<PROVIDERS> Allows you to specify the template providers that TT will use.
Download (untitled) / with headers
text/plain 113b
Just got a suggestion on IRC: <Khisanth> Catalyst::Utils::ensure_class_loaded and probably avoid the all caps
Subject: template_class.diff
Download template_class.diff
text/x-diff 1.3k
Index: lib/Catalyst/View/TT.pm =================================================================== --- lib/Catalyst/View/TT.pm (revision 13602) +++ lib/Catalyst/View/TT.pm (working copy) @@ -9,6 +9,7 @@ use Template::Timer; use MRO::Compat; use Scalar::Util qw/blessed weaken/; +use Catalyst::Utils; our $VERSION = '0.35'; @@ -186,8 +187,11 @@ } } + my $template_class = delete $config->{template_class} || "Template"; + Catalyst::Utils::ensure_class_loaded($template_class); + $self->{template} = - Template->new($config) || do { + $template_class->new($config) || do { my $error = Template->error(); $c->log->error($error); $c->error($error); @@ -564,6 +568,11 @@ In a future release, C<< render_die => 1 >> will become the default if unspecified. +=head2 C<template_class> + +The class to load instead of L<Template>. L<Template::HTML> is a valid value +for example. Useful if you wan't to use modules derived from Template.pm. + =head2 template_vars Returns a list of keys/values to be used as the catalyst variables in the @@ -631,7 +640,7 @@ =head2 C<TEMPLATE_EXTENSION> -a sufix to add when looking for templates bases on the C<match> method in L<Catalyst::Request>. +a suffix to add when looking for templates bases on the C<match> method in L<Catalyst::Request>. For example:
Since this feature is now in, this ticket can be closed. :)
Thanks!


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.