Show the name of variable that is null or missing
If Compliler.nullValue contains a substring "{{name}}", then this substring
will be replaced with the name of variable.
For example, if nullValue="?{{name}}?" and variable is resolved to null,
then string "?foo?" will be used.
This commit is contained in:
@@ -444,6 +444,21 @@ public class MustacheTest
|
||||
"foobar", "{{missing}}{{notmissing}}", context("notmissing", "bar"));
|
||||
}
|
||||
|
||||
@Test public void testMissingValueWithDefaultSubstitution () {
|
||||
test(Mustache.compiler().defaultValue("?{{name}}?"),
|
||||
"?missing?bar", "{{missing}}{{notmissing}}", context("notmissing", "bar"));
|
||||
}
|
||||
|
||||
@Test public void testMissingValueWithDefaultSubstitution2 () {
|
||||
test(Mustache.compiler().defaultValue("{{{{name}}}}"),
|
||||
"{{missing}}bar", "{{missing}}{{notmissing}}", context("notmissing", "bar"));
|
||||
}
|
||||
|
||||
@Test public void testMissingValueWithDefaultSubstitution3 () {
|
||||
test(Mustache.compiler().defaultValue("{{?{{name}}?}}"),
|
||||
"{{?missing?}}bar", "{{missing}}{{notmissing}}", context("notmissing", "bar"));
|
||||
}
|
||||
|
||||
@Test public void testNullValueGetsDefault () {
|
||||
test(Mustache.compiler().defaultValue("foo"),
|
||||
"foobar", "{{nullvar}}{{nonnullvar}}", new Object() {
|
||||
|
||||
Reference in New Issue
Block a user