From d2ce7747a0a44c1278361d69af1d53d193fdc6c8 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Fri, 5 Jul 2013 17:22:51 -0400 Subject: [PATCH] Handle HYDRA_EMAIL_TEMPLATES that are paths Signed-off-by: Shea Levy --- src/lib/Hydra/Plugin/EmailNotification.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib/Hydra/Plugin/EmailNotification.pm b/src/lib/Hydra/Plugin/EmailNotification.pm index 3fc713f9..62d9f0ce 100644 --- a/src/lib/Hydra/Plugin/EmailNotification.pm +++ b/src/lib/Hydra/Plugin/EmailNotification.pm @@ -12,6 +12,7 @@ use File::Slurp; use Template; use Hydra::Helper::Nix; use Hydra::Helper::CatalystUtils; +use FileHandle; my $template = $ENV{'HYDRA_EMAIL_TEMPLATE'} || <new($template, "r"); + if ($fh) { + $template = $fh; + } + } $tt->process(\$template, $vars, \$body) or die "failed to generate email from template"; + if (ref($template) eq "FileHandle") { + $template->close(); + } + # stripping trailing spaces from lines $body =~ s/[\ ]+$//gm;