[Rt-commit] rt branch, 4.0/template-compile-error, created. rt-4.0.18rc1-10-ge4a1a4c
Alex Vandiver
alexmv at bestpractical.com
Tue Oct 8 14:22:20 EDT 2013
The branch, 4.0/template-compile-error has been created
at e4a1a4cb28b42238b9e395492a9cdaebfb3f1d27 (commit)
- Log -----------------------------------------------------------------
commit e4a1a4cb28b42238b9e395492a9cdaebfb3f1d27
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Oct 8 14:17:33 2013 -0400
Catch and warn about template compilation errors
RT warns when saving a template which fails to compile (for example, due
to improperly closed braces). However, if this warning is ignored (or
the template was imported by hand from initialdata), the only hint as to
this came at the debug level:
[debug]: Skipping Scrip #7 because it didn't Prepare
Make the template compilation error explicit, and show which template
contains the error.
diff --git a/lib/RT/Template.pm b/lib/RT/Template.pm
index fd4b511..b8f7a6c 100644
--- a/lib/RT/Template.pm
+++ b/lib/RT/Template.pm
@@ -466,6 +466,12 @@ sub _ParseContentPerl {
TYPE => 'STRING',
SOURCE => $args{Content},
);
+ my ($ok) = $template->compile;
+ unless ($ok) {
+ $RT::Logger->error("Template parsing error in @{[$self->Name]} (#@{[$self->id]}): $Text::Template::ERROR");
+ return ( undef, $self->loc('Template parsing error: [_1]', $Text::Template::ERROR) );
+ }
+
my $is_broken = 0;
my $retval = $template->fill_in(
HASH => $args{TemplateArgs},
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list