summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-05 16:48:45 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-05 16:50:54 -0500
commit38805f6caa8155fecc3f24b74f1a89db1e2543cb (patch)
tree48dc3aa156b65b2fa5cda04483d9fa223a96659e
parentdc22175fdfdc9a100cfc8e72efc6e6f7573835a1 (diff)
downloadtext-handlebars-38805f6caa8155fecc3f24b74f1a89db1e2543cb.tar.gz
text-handlebars-38805f6caa8155fecc3f24b74f1a89db1e2543cb.zip
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
-rw-r--r--lib/Text/Xslate/Syntax/Handlebars.pm13
-rw-r--r--t/helpers.t2
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 => {