treebird/perl/template_helpers.pm
nekobit 9069a17a41 Statuses
FossilOrigin-Name: cff813d2d65c0ce99156358724ecff352e0c5a25feb605f2a46f48b0869cf80b
2022-07-28 05:14:24 +00:00

29 lines
495 B
Perl

package template_helpers;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw( &to_template );
my $template = Template->new(
{
INTERPOLATE => 1,
POST_CHOMP => 1,
EVAL_PERL => 1,
TRIM => 1
});
sub to_template
{
my ($vars, $data) = @_;
my $result;
0 unless ref $data;
0 unless ref $vars;
# TODO HTML error formatting
$template->process($data, $vars, \$result) ||
return $template->error();
$result;
}