From bbc3100461494d371d839ca931088f4840ddf9f5 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 16 Apr 2014 15:07:54 -0400 Subject: treat '..' like any other name (RT#94792) ../../foo should be valid anywhere that baz/bar/foo is valid, so the '..' token should have the same lbp as names --- lib/Text/Xslate/Syntax/Handlebars.pm | 1 + t/block-helpers.t | 56 ++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/lib/Text/Xslate/Syntax/Handlebars.pm b/lib/Text/Xslate/Syntax/Handlebars.pm index 526b0f9..ce21c68 100644 --- a/lib/Text/Xslate/Syntax/Handlebars.pm +++ b/lib/Text/Xslate/Syntax/Handlebars.pm @@ -259,6 +259,7 @@ sub init_symbols { $self->symbol('&')->set_nud($self->can('nud_mark_raw')); $self->symbol('..')->set_nud($self->can('nud_uplevel')); + $self->symbol('..')->lbp(10); $self->infix('=', 20, $self->can('led_equals')); } diff --git a/t/block-helpers.t b/t/block-helpers.t index 3cd6cb8..52e275f 100644 --- a/t/block-helpers.t +++ b/t/block-helpers.t @@ -472,4 +472,60 @@ render_ok( "helper with inverse (inverse has variables)" ); +render_ok( + < +{{#each doc}} +
{{this}}
+{{../../info}} +{{/each}} + +{{/each}} +TEMPLATE + { + info => "hello world", + list => [ { "doc" => [ "a", "b", "c" ] } ], + }, + < +
a
+hello world +
b
+hello world +
c
+hello world + +RENDERED + "object hierarchy access (RT#94792)" +); + +render_ok( + < +{{#each doc}} +
{{this}}
+{{#each ../../info}}{{this}}{{/each}} +{{/each}} + +{{/each}} +TEMPLATE + { + info => [ "hello", "world" ], + list => [ { "doc" => [ "a", "b", "c" ] } ], + }, + < +
a
+helloworld +
b
+helloworld +
c
+helloworld + +RENDERED + "object hierarchy access (RT#94792)" +); + done_testing; -- cgit v1.2.3