emptyStringIsFalse flag now works with any Object.

Previously, only String types were checked for being empty. Now
the Formatter is used to format the Object before checking for
being empty.
This commit is contained in:
Greg Simon
2019-06-27 11:23:19 +10:00
parent fef365c986
commit e01c1b7522
@@ -203,7 +203,7 @@ public class Mustache {
* then empty strings are considered falsey. If {@link #zeroIsFalse} is true, then zero
* values are considered falsey. */
public boolean isFalsey (Object value) {
return (emptyStringIsFalse && "".equals(value)) ||
return (emptyStringIsFalse && "".equals(formatter.format(value))) ||
(zeroIsFalse && (value instanceof Number) && ((Number)value).longValue() == 0);
}