summaryrefslogtreecommitdiffstats
path: root/lib/Text/Handlebars/Compiler.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-02 12:16:42 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-02 12:16:42 -0500
commit0722287d6c04831cdb40b64bae2ca55c24c2f555 (patch)
tree751d92348e4635bf845e1edc1df027fa32b3c4c2 /lib/Text/Handlebars/Compiler.pm
parent2986df9f1eef1112b2221a52bf0a025611ec4e09 (diff)
downloadtext-handlebars-0722287d6c04831cdb40b64bae2ca55c24c2f555.tar.gz
text-handlebars-0722287d6c04831cdb40b64bae2ca55c24c2f555.zip
handle inverted sections
Diffstat (limited to 'lib/Text/Handlebars/Compiler.pm')
-rw-r--r--lib/Text/Handlebars/Compiler.pm10
1 files changed, 6 insertions, 4 deletions
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) {