Class MustacheTemplate
- java.lang.Object
-
- org.pipservices3.expressions.mustache.MustacheTemplate
-
public class MustacheTemplate extends Object
Implements an mustache template class.
-
-
Constructor Summary
Constructors Constructor Description MustacheTemplate()MustacheTemplate(String template)Constructs this class and assigns mustache template.
-
Method Summary
Modifier and Type Method Description voidclear()Cleans up this calculator from all data.voidcreateVariables(Map<String,Object> variables)Populates the specified variables list with variables from parsed mustache.Stringevaluate()Evaluates this mustache template using default variables.StringevaluateWithVariables(Map<String,Object> variables)Evaluates this mustache using specified variables.booleangetAutoVariables()Gets the flag to turn on auto creation of variables for specified mustache.Map<String,Object>getDefaultVariables()The list with default variables.List<MustacheToken>getInitialTokens()The list of original mustache tokens.List<Token>getOriginalTokens()List<MustacheToken>getResultTokens()The list of processed mustache tokens.StringgetTemplate()The mustache template.ObjectgetVariable(Map<String,Object> variables, String name)Gets a variable value from the collection of variablesvoidsetAutoVariables(boolean value)Sets the flag to turn on auto creation of variables for specified mustache.voidsetOriginalTokens(List<Token> value)voidsetTemplate(String value)The mustache template.
-
-
-
Method Detail
-
getTemplate
public String getTemplate()
The mustache template.
-
setTemplate
public void setTemplate(String value) throws Exception
The mustache template.- Throws:
Exception
-
setOriginalTokens
public void setOriginalTokens(List<Token> value) throws MustacheException
- Throws:
MustacheException
-
getAutoVariables
public boolean getAutoVariables()
Gets the flag to turn on auto creation of variables for specified mustache.
-
setAutoVariables
public void setAutoVariables(boolean value)
Sets the flag to turn on auto creation of variables for specified mustache.
-
getDefaultVariables
public Map<String,Object> getDefaultVariables()
The list with default variables.
-
getInitialTokens
public List<MustacheToken> getInitialTokens()
The list of original mustache tokens.
-
getResultTokens
public List<MustacheToken> getResultTokens()
The list of processed mustache tokens.
-
getVariable
public Object getVariable(Map<String,Object> variables, String name)
Gets a variable value from the collection of variables- Parameters:
variables- a collection of variables.name- a variable name to get.- Returns:
- a variable value or
undefined
-
createVariables
public void createVariables(Map<String,Object> variables)
Populates the specified variables list with variables from parsed mustache.- Parameters:
variables- The list of variables to be populated.
-
clear
public void clear()
Cleans up this calculator from all data.
-
evaluate
public String evaluate() throws MustacheException
Evaluates this mustache template using default variables.- Returns:
- the evaluated template
- Throws:
MustacheException
-
evaluateWithVariables
public String evaluateWithVariables(Map<String,Object> variables) throws MustacheException
Evaluates this mustache using specified variables.- Parameters:
variables- The collection of variables- Returns:
- the evaluated template
- Throws:
MustacheException
-
-