Subject: | Patchfile included. Support HTML::Template->new options. |
Hello.
Subj. Please, apply patchfile.
Regards.
Subject: | up.patch |
diff --git a/HTMLTemplateRenderer.pm b/HTMLTemplateRenderer.pm
index ab2e2df..e0f8fab 100644
--- a/HTMLTemplateRenderer.pm
+++ b/HTMLTemplateRenderer.pm
@@ -6,7 +6,7 @@ use HTML::Template;
our $VERSION = '0.01';
sub register {
- my ($self, $app) = @_;
+ my ($self, $app, $conf) = @_;
$app->renderer->add_handler(
tmpl => sub {
@@ -31,7 +31,9 @@ sub register {
my %tmpl_params = %{$c->stash};
- my $t = HTML::Template->new(%t_options);
+ my $t = HTML::Template->new(%t_options,
+ %{$conf->{tmpl_new_opts} || {}},
+ %{delete $tmpl_params{tmpl_new_opts} || {}});
unless($t) { die "ERROR: No template created"; }
@@ -54,9 +56,20 @@ Mojolicious::Plugin::HTMLTemplateRenderer - Mojolicious Plugin
# Mojolicious
$self->plugin('HTMLTemplateRenderer');
+
# Mojolicious::Lite
plugin 'HTMLTemplateRenderer';
+ # Render HTML::Template handler and post 'utf8 => 1' option for next HTML::Template->new call
+ get '/' => sub{
+ my $self = shift;
+ $self->render('bender', handler => 'tmpl', tmpl_new_opts => {utf8 => 1});
+ }
+
+
+ # Set default options for all HTML::Template->new calls
+ plugin 'HTMLTemplateRenderer', tmpl_new_opts => {blind_cache => 1, open_mode => '<:encoding(UTF-16)'};
+
=head1 DESCRIPTION
L<Mojolicious::Plugin::HTMLTemplateRenderer> is a L<Mojolicious> plugin.