Skip to content

Commit fbf6e91

Browse files
committed
global property "size" overwrites local {{size}} #552
1 parent daec399 commit fbf6e91

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.github.jknack.handlebars.issues;
2+
3+
import com.github.jknack.handlebars.Context;
4+
import com.github.jknack.handlebars.context.FieldValueResolver;
5+
import com.github.jknack.handlebars.context.JavaBeanValueResolver;
6+
import com.github.jknack.handlebars.context.MapValueResolver;
7+
import com.github.jknack.handlebars.context.MethodValueResolver;
8+
import com.github.jknack.handlebars.v4Test;
9+
import org.junit.Test;
10+
11+
import java.util.Arrays;
12+
13+
public class Issue552 extends v4Test {
14+
15+
@Override protected Object configureContext(Object context) {
16+
return Context.newBuilder(context)
17+
.resolver(MapValueResolver.INSTANCE,
18+
FieldValueResolver.INSTANCE,
19+
JavaBeanValueResolver.INSTANCE,
20+
MethodValueResolver.INSTANCE)
21+
.build();
22+
}
23+
24+
@Test
25+
public void shouldKeepContextOnBlockParameter() throws Exception {
26+
shouldCompileTo("{{> button size='large'}}",
27+
$("hash", $, "partials", $("button", "<button class=\"button-{{size}}>\n"
28+
+ " Button with size {{size}}\n"
29+
+ "</button>")),
30+
"<button class=\"button-large>\n"
31+
+ " Button with size large\n"
32+
+ "</button>");
33+
}
34+
}

handlebars/src/test/java/com/github/jknack/handlebars/issues/Issue567.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ public void shouldKeepContextOnBlockParameter() throws Exception {
1414
+ "{{/each}}",
1515
$("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}");
1616
}
17-
}
17+
}

0 commit comments

Comments
 (0)