summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Action/ExtractCustomFieldValuesWithCodeInTemplate.pm
blob: e05966be23d57f852ba3130991318906876e2963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;