diff --git a/Changes b/Changes index a1df325..281975a 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for MojoX-Renderer-TT 0.03 + - Update to work with named parameters in new version of Mojo + - Instead of "tx" pass the context in the "c" variable - Rename "new" to "build" - Add real tests (Viacheslav Tikhanovskii) - Update to work with new error handling in Mojo diff --git a/lib/MojoX/Renderer/TT.pm b/lib/MojoX/Renderer/TT.pm index 1b80d3d..629e8c3 100644 --- a/lib/MojoX/Renderer/TT.pm +++ b/lib/MojoX/Renderer/TT.pm @@ -48,17 +48,22 @@ sub _init { } sub _render { - my ($self, $mojo, $path, $output, $tx, $args) = @_; + my ($self, $mojo, $args) = @_; - $args ||= {}; + $args->{args} ||= {}; #use Data::Dump qw(dump); #warn dump(\$args); - unless ($self->tt->process($path, {%$args, tx => $tx}, $output, {binmode => ":utf8"})) { + unless ($self->tt->process($args->{path}, + {%{$args->{args}}, + c => $args->{c}}, + $args->{output}, + {binmode => ":utf8"})) { Carp::carp $self->tt->error . "\n"; return 0; - } else { + } + else { return 1; } } @@ -130,7 +135,6 @@ Ask Bjørn Hansen, C<< >> * Better support non-Mojolicious frameworks * Don't require the mojo parameter * Move the default template cache directory? - * Should the "tx" tpl parameter be called "c" (for context) instead? * Better way to pass parameters to the templates? (stash) * More sophisticated default search path? diff --git a/t/render.t b/t/render.t index e98fac8..52981b9 100644 --- a/t/render.t +++ b/t/render.t @@ -14,10 +14,10 @@ my $mt = MojoX::Renderer::TT->build; my $output; my $rv; -$rv = $mt->(undef, 't/render/template.tt2', \$output); +$rv = $mt->(undef, { path => 't/render/template.tt2', output => \$output }); is($rv, 1); is($output, "4\n"); -$rv = $mt->(undef, 't/render/template-error.tt2', \$output); +$rv = $mt->(undef, { path => 't/render/template-error.tt2', output => \$output }); is($rv, 0); ok($output);