Class MustacheTemplate

java.lang.Object
org.pipservices3.expressions.mustache.MustacheTemplate

public class MustacheTemplate extends Object
Implements an mustache template class.
  • Constructor Details

    • MustacheTemplate

      public MustacheTemplate(String template) throws Exception
      Constructs this class and assigns mustache template.
      Parameters:
      template - The mustache template.
      Throws:
      Exception
    • MustacheTemplate

      public MustacheTemplate() throws Exception
      Throws:
      Exception
  • Method Details

    • getTemplate

      public String getTemplate()
      The mustache template.
    • setTemplate

      public void setTemplate(String value) throws Exception
      The mustache template.
      Throws:
      Exception
    • getOriginalTokens

      public List<Token> getOriginalTokens()
    • 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