From 0722287d6c04831cdb40b64bae2ca55c24c2f555 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 2 Oct 2012 12:16:42 -0500 Subject: handle inverted sections --- lib/Text/Handlebars/Compiler.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/Text/Handlebars/Compiler.pm') diff --git a/lib/Text/Handlebars/Compiler.pm b/lib/Text/Handlebars/Compiler.pm index 2150bba..5f112fc 100644 --- a/lib/Text/Handlebars/Compiler.pm +++ b/lib/Text/Handlebars/Compiler.pm @@ -11,10 +11,12 @@ sub _generate_block { my $self = shift; my ($node) = @_; - return ( - $self->_localize_vars($node->first), - (map { $self->compile_ast($_) } @{ $node->second }), - ); + my @compiled = map { $self->compile_ast($_) } @{ $node->second }; + + unshift @compiled, $self->_localize_vars($node->first) + if $node->first; + + return @compiled; } if (0) { -- cgit v1.2.3-54-g00ecf