Class MustacheTemplate


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

      • MustacheTemplate

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

      • getTemplate

        public String getTemplate()
        The mustache template.
      • getOriginalTokens

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