Test that names are being processed in partials; fixed exception on attempt to
use partials when unconfigured; moved partials tests down into a more sensible location among the tests.
This commit is contained in:
@@ -21,20 +21,6 @@ import org.junit.Test;
|
|||||||
*/
|
*/
|
||||||
public class MustacheTest
|
public class MustacheTest
|
||||||
{
|
{
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void testDefaultTemplateIncludeBehavior () {
|
|
||||||
test(null, "{{>foo}}", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTemplateIncludeBehavior () {
|
|
||||||
test(Mustache.compiler().withLoader(new Mustache.TemplateLoader() {
|
|
||||||
public Reader getTemplate (String name) {
|
|
||||||
return new StringReader("inside:{{bar}}");
|
|
||||||
}
|
|
||||||
}), "foo inside:foo foo", "{{bar}} {{>foo}} {{bar}}", context("bar", "foo"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test public void testSimpleVariable () {
|
@Test public void testSimpleVariable () {
|
||||||
test("bar", "{{foo}}", context("foo", "bar"));
|
test("bar", "{{foo}}", context("foo", "bar"));
|
||||||
}
|
}
|
||||||
@@ -131,6 +117,23 @@ public class MustacheTest
|
|||||||
test("foobar", "foo{{! nothing to see here}}bar", new Object());
|
test("foobar", "foo{{! nothing to see here}}bar", new Object());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected=UnsupportedOperationException.class)
|
||||||
|
public void testPartialUseWhenUnconfigured () {
|
||||||
|
test(null, "{{>foo}}", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test public void testPartial () {
|
||||||
|
test(Mustache.compiler().withLoader(new Mustache.TemplateLoader() {
|
||||||
|
public Reader getTemplate (String name) {
|
||||||
|
if (name.equals("foo")) {
|
||||||
|
return new StringReader("inside:{{bar}}");
|
||||||
|
} else {
|
||||||
|
return new StringReader("nonfoo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}), "foo inside:foo nonfoo foo", "{{bar}} {{>foo}} {{>baz}} {{bar}}", context("bar", "foo"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test public void testUnescapeHTML () {
|
@Test public void testUnescapeHTML () {
|
||||||
assertEquals("<b>", Mustache.compiler().escapeHTML(true).compile("{{&a}}").
|
assertEquals("<b>", Mustache.compiler().escapeHTML(true).compile("{{&a}}").
|
||||||
execute(context("a", "<b>")));
|
execute(context("a", "<b>")));
|
||||||
|
|||||||
Reference in New Issue
Block a user