-
-
Save anonymous/a9d3d416c66b86fa7980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Template.pm b/lib/Mojo/Template.pm | |
index 037ec6c..60920ff 100644 | |
--- a/lib/Mojo/Template.pm | |
+++ b/lib/Mojo/Template.pm | |
@@ -274,7 +274,7 @@ sub _wrap { | |
my $num = () = $code =~ /\n/g; | |
my $head = $self->_line(1); | |
$head .= "\npackage @{[$self->namespace]}; use Mojo::Base -strict;"; | |
- $code = "$head sub { my \$_M = ''; @{[$self->prepend]}; do { $code\n"; | |
+ $code = "$head sub { my \$_M = ''; @{[$self->prepend]}; { $code\n"; | |
$code .= $self->_line($num + 1) . "\n@{[$self->append]}; \$_M } };"; | |
warn "-- Code for @{[$self->name]}\n@{[encode 'UTF-8', $code]}\n\n" if DEBUG; | |
diff --git a/lib/Mojolicious/Plugin/EPRenderer.pm b/lib/Mojolicious/Plugin/EPRen | |
index a662155..7822808 100644 | |
--- a/lib/Mojolicious/Plugin/EPRenderer.pm | |
+++ b/lib/Mojolicious/Plugin/EPRenderer.pm | |
@@ -34,10 +34,11 @@ sub register { | |
unless $self->{helpers}; | |
# Stash values (every time) | |
- my $prepend = 'my $self = my $c = shift; my $_S = $c->stash;'; | |
+ my $prepend = 'my $self = my $c = shift; my $_S = $c->stash; {'; | |
$prepend .= join '', map {" my \$$_ = \$_S->{'$_'};"} @keys; | |
+ $mt->prepend($prepend . $mt->prepend)->append('}' . $mt->append); | |
- $cache->set($key => $mt->prepend($prepend . $mt->prepend)); | |
+ $cache->set($key => $mt); | |
} | |
# Make current controller available | |
diff --git a/t/mojolicious/app.t b/t/mojolicious/app.t | |
index e911f2b..41831e7 100644 | |
--- a/t/mojolicious/app.t | |
+++ b/t/mojolicious/app.t | |
@@ -65,6 +65,8 @@ is $t->app->renderer->template_handler( | |
is $t->app->build_controller->req->url, '', 'no URL'; | |
is $t->app->build_controller->render_to_string('does_not_exist'), undef, | |
'no result'; | |
+is $t->app->build_controller->render_to_string(inline => '%= $c', c => 'foo'), | |
+ "foo\n", 'right result'; | |
# Missing methods and functions (AUTOLOAD) | |
eval { $t->app->missing }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment