|
1 | 1 | package com.github.mustachejava; |
2 | 2 |
|
| 3 | +import com.github.mustachejava.reflect.SimpleObjectHandler; |
3 | 4 | import com.github.mustachejava.util.CapturingMustacheVisitor; |
4 | 5 | import com.github.mustachejavabenchmarks.JsonCapturer; |
5 | 6 | import com.github.mustachejavabenchmarks.JsonInterpreterTest; |
@@ -97,6 +98,31 @@ int taxed_value() { |
97 | 98 | assertEquals(getContents(root, "simple.txt"), sw.toString()); |
98 | 99 | } |
99 | 100 |
|
| 101 | + private class OkGenerator { |
| 102 | + public boolean isItOk() { |
| 103 | + return true; |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + public void testNestedAccessWithSimpleObjectHandler() throws IOException { |
| 108 | + assertEquals(getOutput(false), getOutput(true)); |
| 109 | + } |
| 110 | + |
| 111 | + private String getOutput(final boolean setObjectHandler) { |
| 112 | + final DefaultMustacheFactory mustacheFactory = new DefaultMustacheFactory(); |
| 113 | + if (setObjectHandler) { |
| 114 | + mustacheFactory.setObjectHandler(new SimpleObjectHandler()); |
| 115 | + } |
| 116 | + final Mustache defaultMustache = mustacheFactory.compile(new StringReader("{{#okGenerator.isItOk}}{{okGenerator.isItOk}}{{/okGenerator.isItOk}}"), "Test template"); |
| 117 | + final Map<String, Object> params = new HashMap<String, Object>(); |
| 118 | + params.put("okGenerator", new OkGenerator()); |
| 119 | + final Writer writer = new StringWriter(); |
| 120 | + defaultMustache.execute(writer, params); |
| 121 | + return writer.toString(); |
| 122 | + |
| 123 | + } |
| 124 | + |
| 125 | + |
100 | 126 | public void testMultipleWrappers() throws MustacheException, IOException, ExecutionException, InterruptedException { |
101 | 127 | MustacheFactory c = createMustacheFactory(); |
102 | 128 | Mustache m = c.compile("simple.html"); |
|
0 commit comments