Added compiler option to provide defaults for missing values
Call missingVariableValue(value) on a Compiler object to get a new version that will insert "value" for missing values (rather than throwing an exception). Useful when you have templates you would rather generated *something* instead of erroring or for when objects may have null values themselves.
This commit is contained in:
@@ -126,6 +126,12 @@ public class Template
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Object getValueWithDefault (Context ctx, String name, int line)
|
||||
{
|
||||
Object value = getValue(ctx, name, line);
|
||||
return value != null? value : _compiler.missingVariableValue;
|
||||
}
|
||||
|
||||
protected Object getValueIn (Object data, String name, int line)
|
||||
{
|
||||
if (data == null) {
|
||||
|
||||
Reference in New Issue
Block a user