diff --git a/compiler/src/test/java/com/github/mustachejava/DynamicNamesTest.java b/compiler/src/test/java/com/github/mustachejava/DynamicNamesTest.java new file mode 100644 index 00000000..cd8cdaf8 --- /dev/null +++ b/compiler/src/test/java/com/github/mustachejava/DynamicNamesTest.java @@ -0,0 +1,29 @@ +package com.github.mustachejava; + +import org.junit.Test; + +import java.io.StringWriter; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class DynamicNamesTest { + + @Test + public void testIssue305() { + MustacheFactory mf = new DefaultMustacheFactory(); + Mustache m = mf.compile("pd-test.mustache"); + + StringWriter writer = new StringWriter(); + + Map scope = new java.util.HashMap<>(); + scope.put("name", "dn"); + m.execute(writer, scope); + + String result = writer.toString(); + + assertEquals("Do dynamic names work?\n" + + "\n" + + "Answer: Mustache Do!", result); + } +} diff --git a/compiler/src/test/resources/dn.mustache b/compiler/src/test/resources/dn.mustache new file mode 100644 index 00000000..e8b19e72 --- /dev/null +++ b/compiler/src/test/resources/dn.mustache @@ -0,0 +1 @@ +Mustache Do! \ No newline at end of file diff --git a/compiler/src/test/resources/pd-test.mustache b/compiler/src/test/resources/pd-test.mustache new file mode 100644 index 00000000..2829e604 --- /dev/null +++ b/compiler/src/test/resources/pd-test.mustache @@ -0,0 +1,3 @@ +Do dynamic names work? + +Answer: {{>*name}} \ No newline at end of file