Subject: | Ability to load other classes beside Template.pm |
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 |
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.