Let's add a test illustrating that default values are used for variables which
resolve to null.
This commit is contained in:
@@ -299,6 +299,14 @@ public class MustacheTest
|
||||
"foobar", "{{missing}}{{notmissing}}", context("notmissing", "bar"));
|
||||
}
|
||||
|
||||
@Test public void testNullValueGetsDefault () {
|
||||
test(Mustache.compiler().defaultValue("foo"),
|
||||
"foobar", "{{nullvar}}{{nonnullvar}}", new Object() {
|
||||
String nonnullvar = "bar";
|
||||
String nullvar = null;
|
||||
});
|
||||
}
|
||||
|
||||
protected void test (Mustache.Compiler compiler, String expected, String template, Object ctx)
|
||||
{
|
||||
assertEquals(expected, compiler.compile(template).execute(ctx));
|
||||
|
||||
Reference in New Issue
Block a user