null values can shadow parent context now. Improve test a little.

This commit is contained in:
Tom Insam
2012-08-22 15:19:00 +01:00
parent 718218098f
commit 2b337b8770
3 changed files with 7 additions and 6 deletions
@@ -37,7 +37,11 @@ public class BasicCollector implements Mustache.Collector
protected static final Mustache.VariableFetcher MAP_FETCHER = new Mustache.VariableFetcher() {
public Object get (Object ctx, String name) throws Exception {
return ((Map<?,?>)ctx).get(name);
if (((Map<?,?>)ctx).containsKey(name)) {
return ((Map<?,?>)ctx).get(name);
} else {
return Template.NO_FETCHER_FOUND;
}
}
};
@@ -140,10 +140,6 @@ public class Template
Object value = getValueIn(ctx.data, name, line);
if (value == NO_FETCHER_FOUND) {
// preserve variableMissing
} else if (value == null) {
// we found a fetcher, and it returned null; so we keep searching our parents, but
// we won't freak out about a missing variable if we have a nullValue configured
variableMissing = false;
} else {
return value;
}