Moved falsey-ness detection into compiler.
Fixes #39. This fixes a bug where falsey values were not properly triggering inverted sections, and consolidates some logic. Also did some renaming. Couldn't help myself.
This commit is contained in:
@@ -146,9 +146,17 @@ public class MustacheTest
|
||||
}
|
||||
|
||||
@Test public void testSectionWithFalseyEmptyString () {
|
||||
test(Mustache.compiler().emptyStringIsFalse(true), "", "{{#foo}}test{{/foo}}", new Object() {
|
||||
Object ctx = new Object() {
|
||||
String foo = "";
|
||||
});
|
||||
String bar = "nonempty";
|
||||
};
|
||||
// test normal sections with falsey empty string
|
||||
Mustache.Compiler compiler = Mustache.compiler().emptyStringIsFalse(true);
|
||||
test(compiler, "", "{{#foo}}test{{/foo}}", ctx);
|
||||
test(compiler, "test", "{{#bar}}test{{/bar}}", ctx);
|
||||
// test inverted sections with falsey empty string
|
||||
test(compiler, "test", "{{^foo}}test{{/foo}}", ctx);
|
||||
test(compiler, "", "{{^bar}}test{{/bar}}", ctx);
|
||||
}
|
||||
|
||||
@Test public void testSectionWithNonFalseyZero () {
|
||||
|
||||
Reference in New Issue
Block a user