forked from lix-project/hydra
Handle HYDRA_EMAIL_TEMPLATES that are paths
Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
parent
304f8a5714
commit
d2ce7747a0
|
@ -12,6 +12,7 @@ use File::Slurp;
|
||||||
use Template;
|
use Template;
|
||||||
use Hydra::Helper::Nix;
|
use Hydra::Helper::Nix;
|
||||||
use Hydra::Helper::CatalystUtils;
|
use Hydra::Helper::CatalystUtils;
|
||||||
|
use FileHandle;
|
||||||
|
|
||||||
|
|
||||||
my $template = $ENV{'HYDRA_EMAIL_TEMPLATE'} || <<EOF;
|
my $template = $ENV{'HYDRA_EMAIL_TEMPLATE'} || <<EOF;
|
||||||
|
@ -92,9 +93,19 @@ sub buildFinished {
|
||||||
};
|
};
|
||||||
|
|
||||||
my $body;
|
my $body;
|
||||||
|
if (-e $template) {
|
||||||
|
my $fh = FileHandle->new($template, "r");
|
||||||
|
if ($fh) {
|
||||||
|
$template = $fh;
|
||||||
|
}
|
||||||
|
}
|
||||||
$tt->process(\$template, $vars, \$body)
|
$tt->process(\$template, $vars, \$body)
|
||||||
or die "failed to generate email from template";
|
or die "failed to generate email from template";
|
||||||
|
|
||||||
|
if (ref($template) eq "FileHandle") {
|
||||||
|
$template->close();
|
||||||
|
}
|
||||||
|
|
||||||
# stripping trailing spaces from lines
|
# stripping trailing spaces from lines
|
||||||
$body =~ s/[\ ]+$//gm;
|
$body =~ s/[\ ]+$//gm;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue