From 52ea1ea3f9d1bd29dcb7b056536a8b3f58268dee Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 8 Oct 2012 13:38:36 -0500 Subject: implement hash args for normal helpers --- lib/Text/Handlebars/Compiler.pm | 11 +++++++++-- lib/Text/Xslate/Syntax/Handlebars.pm | 2 +- t/helpers.t | 2 -- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/Text/Handlebars/Compiler.pm b/lib/Text/Handlebars/Compiler.pm index a358d2e..54f760d 100644 --- a/lib/Text/Handlebars/Compiler.pm +++ b/lib/Text/Handlebars/Compiler.pm @@ -103,8 +103,15 @@ sub _generate_call { line => $node->line, ); - push @{ $node->first->second }, $parser->call($make_hash, @hash); - $node->second(\@args); + my $hash = $parser->call($make_hash, @hash); + + if ($node->first->arity eq 'call' && $node->first->first->id eq '(make_block_helper)') { + push @{ $node->first->second }, $hash; + $node->second(\@args); + } + else { + $node->second([ @args, $hash ]); + } } return $self->SUPER::_generate_call($node); diff --git a/lib/Text/Xslate/Syntax/Handlebars.pm b/lib/Text/Xslate/Syntax/Handlebars.pm index 7d28824..0929f2c 100644 --- a/lib/Text/Xslate/Syntax/Handlebars.pm +++ b/lib/Text/Xslate/Syntax/Handlebars.pm @@ -309,6 +309,7 @@ sub nud_name { my $call = $self->call($name); if ($name->is_helper) { + $call->is_helper(1); push @{ $call->second }, $self->vars; } @@ -419,7 +420,6 @@ sub std_block { ? $block{else}{raw_text}->clone : $self->literal('')), ), - is_helper => 1, ); return $self->print_raw($name); } diff --git a/t/helpers.t b/t/helpers.t index 51ab9ac..515d540 100644 --- a/t/helpers.t +++ b/t/helpers.t @@ -60,7 +60,6 @@ RENDERED "helpers with literal args" ); -{ local $TODO = "unimplemented"; render_ok( { helpers => { @@ -91,6 +90,5 @@ TEMPLATE RENDERED "helpers with literal args" ); -} done_testing; -- cgit v1.2.3