diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-07-17 09:04:06 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-07-17 09:04:06 -0700 |
commit | 91dbe4c3834f38d428367d9a1e2c6cf9ea9d84a4 (patch) | |
tree | e4d6a63b75a2e3df13fdd35e24ae98ec8b3567cb /rt/lib/RT/Action/ExtractCustomFieldValuesWithCodeInTemplate.pm | |
parent | 2101a32bdf12abdb2afdb654d6da30975ddd4fc9 (diff) | |
parent | d0fcbc3d04250ec54cb5dea7abcc58d1f45d78b1 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'rt/lib/RT/Action/ExtractCustomFieldValuesWithCodeInTemplate.pm')
-rw-r--r-- | rt/lib/RT/Action/ExtractCustomFieldValuesWithCodeInTemplate.pm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/rt/lib/RT/Action/ExtractCustomFieldValuesWithCodeInTemplate.pm b/rt/lib/RT/Action/ExtractCustomFieldValuesWithCodeInTemplate.pm new file mode 100644 index 000000000..e05966be2 --- /dev/null +++ b/rt/lib/RT/Action/ExtractCustomFieldValuesWithCodeInTemplate.pm @@ -0,0 +1,30 @@ +package RT::Action::ExtractCustomFieldValuesWithCodeInTemplate; +use strict; +use warnings; + +use base qw(RT::Action::ExtractCustomFieldValues); + +sub TemplateContent { + my $self = shift; + my $is_broken = 0; + + my $content = $self->TemplateObj->Content; + + my $template = Text::Template->new(TYPE => 'STRING', SOURCE => $content); + my $new_content = $template->fill_in( + BROKEN => sub { + my (%args) = @_; + $RT::Logger->error("Template parsing error: $args{error}") + unless $args{error} =~ /^Died at /; # ignore intentional die() + $is_broken++; + return undef; + }, + ); + + return (undef, $self->loc('Template parsing error')) if $is_broken; + + return $new_content; +} + +1; + |