I want to render .html.ep
templates using Mojolicious rendering engine in a standalone script which sends e-mails and is run from cron:
#!/usr/bin/perl
use feature ':5.10';
use Mojo::Base -strict;
use Mojolicious::Renderer;
use Data::Dumper;
my $renderer = Mojolicious::Renderer->new();
push @{$renderer->paths}, '/app/templates';
my $template = $renderer->get_data_template({
template => 'template_name',
format => 'html',
handler => 'ep'
});
print Dumper($template) . "\n";
However, $template
is always undefined.
The template file is /app/templates/template_name.html.ep
.
What am I doing wrong?
get_data_template
is for__DATA__
sections, not files. – Dynasty