Description
The MustacheTemplate class allows you to implement a Mustache template class.
Constructors
Constructs this class and assigns a mustache template.
publicMustacheTemplate(String template) throws Exception
- template: String - mustache template.
Properties
autoVariables
Flag to turn on auto-creation of variables for the Mustache template.
privateboolean _autoVariables = true
defaultVariables
List with default variables.
private finalMap<String, Object> _defaultVariables = new HashMap<>()
Instance methods
clear
Cleans up this calculator.
publicvoid clear()
createVariables
Populates the specified variables list with variables obtained from a parsed Mustache template.
publicvoid createVariables(Map<String, Object> variables)
- variables: Map<String, Object> - List of variables to be populated.
evaluate
Evaluates this Mustache template using default variables.
publicString evaluate() throws MustacheException
- returns: string - evaluated template.
evaluateWithVariables
Evaluates this Mustache using specified variables.
publicString evaluateWithVariables(Map<String, Object> variables) throws MustacheException
- variables: Map<String, Object> - collection of variables.
- returns: String - evaluated template
getVariable
Gets a variable value from the collection of variables.
publicObject getVariable(Map<String, Object> variables, String name)
- variables: Map<String, Object> - collection of variables.
- name: String - variable name to get.
- returns: Object - variable value or undefined.