From 38805f6caa8155fecc3f24b74f1a89db1e2543cb Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 5 Oct 2012 16:48:45 -0500 Subject: hack to make normal helpers work for now thinking about it some more, defining helpers separately from builtin functions is a better idea, because helpers have to automatically receive the context object, which makes them different from normal functions. right now, i'm just special-casing mark_raw to avoid passing the context object to it, but it needs to be more general than that --- lib/Text/Xslate/Syntax/Handlebars.pm | 13 +++++++++++-- t/helpers.t | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Text/Xslate/Syntax/Handlebars.pm b/lib/Text/Xslate/Syntax/Handlebars.pm index bf10ab5..495fd47 100644 --- a/lib/Text/Xslate/Syntax/Handlebars.pm +++ b/lib/Text/Xslate/Syntax/Handlebars.pm @@ -298,7 +298,17 @@ sub nud_name { my $name = $self->SUPER::nud_name($symbol); - return $self->call($name); + my $call = $self->call($name); + + use Data::Dump; ddx($self->token); + if ($self->token->is_defined) { + push @{ $call->second }, $self->expression(0); + } + elsif ($name->id ne 'mark_raw') { + push @{ $call->second }, $self->vars; + } + + return $call; } sub led_name { @@ -445,7 +455,6 @@ sub std_block { ($block{else} ? $block{else}{raw_text}->clone : $self->literal('')), - $self->vars, @{ $name->second }, ), ); diff --git a/t/helpers.t b/t/helpers.t index 52b7e09..98a72ba 100644 --- a/t/helpers.t +++ b/t/helpers.t @@ -7,7 +7,6 @@ use Test::Handlebars; use Text::Xslate 'mark_raw'; -{ local $TODO = "unimplemented"; render_ok( { function => { @@ -61,6 +60,7 @@ RENDERED "helpers with literal args" ); +{ local $TODO = "unimplemented"; render_ok( { function => { -- cgit v1.2.3