summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-08 13:38:36 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-08 13:38:36 -0500
commit52ea1ea3f9d1bd29dcb7b056536a8b3f58268dee (patch)
tree97ce9384137924d90170047c615438023fa09f18
parent6d3b76546c92f15aadc2a9c4b7568411e49ccfbe (diff)
downloadtext-handlebars-52ea1ea3f9d1bd29dcb7b056536a8b3f58268dee.tar.gz
text-handlebars-52ea1ea3f9d1bd29dcb7b056536a8b3f58268dee.zip
implement hash args for normal helpers
-rw-r--r--lib/Text/Handlebars/Compiler.pm11
-rw-r--r--lib/Text/Xslate/Syntax/Handlebars.pm2
-rw-r--r--t/helpers.t2
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;