Some tidying up, name changes and clarifications. I went with "defaultValue"
rather than "missingVariableValue" because the value is used any time a
variable resolves to null, not necessarily just when it is missing. If you
have a context like:
new Object() {
String foo = null;
}
and reference {{foo}} in your template, foo is not missing, per se, but the
default value will still be used for it.
This commit is contained in:
@@ -126,10 +126,14 @@ public class Template
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Object getValueWithDefault (Context ctx, String name, int line)
|
||||
/**
|
||||
* Returns the value for the specified variable, or the configured default value if the
|
||||
* variable resolves to null. See {@link #getValue}.
|
||||
*/
|
||||
protected Object getValueOrDefault (Context ctx, String name, int line)
|
||||
{
|
||||
Object value = getValue(ctx, name, line);
|
||||
return value != null? value : _compiler.missingVariableValue;
|
||||
return (value == null) ? _compiler.defaultValue : value;
|
||||
}
|
||||
|
||||
protected Object getValueIn (Object data, String name, int line)
|
||||
|
||||
Reference in New Issue
Block a user