9069a17a41
FossilOrigin-Name: cff813d2d65c0ce99156358724ecff352e0c5a25feb605f2a46f48b0869cf80b
29 lines
495 B
Perl
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;
|
|
}
|