Skip to content

Commit daec399

Browse files
committed
Block parameters break dumping the context fix #567
1 parent beb25e6 commit daec399

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

handlebars/src/main/java/com/github/jknack/handlebars/Context.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public Object get(final List<PathExpression> path) {
8484
return parent.model;
8585
}
8686
// path variable should resolve from parent :S
87-
if (key.startsWith(".")) {
87+
if (key.startsWith(".") && path.size() > 1) {
8888
return parent.get(path.subList(1, path.size()));
8989
}
9090
return super.get(path);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.github.jknack.handlebars.issues;
2+
3+
import com.github.jknack.handlebars.v4Test;
4+
import org.junit.Test;
5+
6+
import java.util.Arrays;
7+
8+
public class Issue567 extends v4Test {
9+
10+
@Test
11+
public void shouldKeepContextOnBlockParameter() throws Exception {
12+
shouldCompileTo("{{#each foo as |v k|}}"
13+
+ " context is {{{.}}}"
14+
+ "{{/each}}",
15+
$("hash", $("foo", Arrays.asList("a", "b", "c"))), " context is {v=a, k=0} context is {v=b, k=1} context is {v=c, k=2}");
16+
}
17+
}

0 commit comments

Comments
 (0)