[Rt-commit] rt branch, new-style-templates, updated. rt-3.8.8-185-gbd8ce66
Shawn Moore
sartak at bestpractical.com
Tue Jul 20 23:04:22 EDT 2010
The branch, new-style-templates has been updated
via bd8ce6688c6684589a98bf7bf74aa393bd758c47 (commit)
from 2980129197d1fa1f3b692df9952d26bd9af337f4 (commit)
Summary of changes:
lib/RT/Template_Overlay.pm | 45 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 39 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit bd8ce6688c6684589a98bf7bf74aa393bd758c47
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Jul 20 23:05:12 2010 -0400
Factor the template-specific stuff out of _ParseContent into new methods
_ParseContentFull for full-code Text::Template
_ParseContentSimple for simple (and safe) variable subsitutition (to
be implemented)
diff --git a/lib/RT/Template_Overlay.pm b/lib/RT/Template_Overlay.pm
index 68332f3..f8fcbfb 100755
--- a/lib/RT/Template_Overlay.pm
+++ b/lib/RT/Template_Overlay.pm
@@ -388,10 +388,6 @@ sub _ParseContent {
# We need to untaint the content of the template, since we'll be working
# with it
$content =~ s/^(.*)$/$1/;
- my $template = Text::Template->new(
- TYPE => 'STRING',
- SOURCE => $content
- );
$args{'Ticket'} = delete $args{'TicketObj'} if $args{'TicketObj'};
$args{'Transaction'} = delete $args{'TransactionObj'} if $args{'TransactionObj'};
@@ -412,23 +408,60 @@ sub _ParseContent {
$args{ $key } = \$val;
}
+ if ($self->Type eq 'Full') {
+ return $self->_ParseContentFull(
+ Content => $content,
+ TemplateArgs => \%args,
+ );
+ }
+ else {
+ return $self->_ParseContentSimple(
+ Content => $content,
+ TemplateArgs => \%args,
+ );
+ }
+}
+
+# uses Text::Template for Full templates
+sub _ParseContentFull {
+ my $self = shift;
+ my %args = (
+ Content => undef,
+ TemplateArgs => {},
+ @_,
+ );
+ my $template = Text::Template->new(
+ TYPE => 'STRING',
+ SOURCE => $args{Content},
+ );
my $is_broken = 0;
my $retval = $template->fill_in(
- HASH => \%args,
+ HASH => $args{TemplateArgs},
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 ($retval);
}
+sub _ParseContentSimple {
+ my $self = shift;
+ my %args = (
+ Content => undef,
+ TemplateArgs => {},
+ @_,
+ );
+
+ return $args{Content};
+}
+
sub _DowngradeFromHTML {
my $self = shift;
my $orig_entity = $self->MIMEObj;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list