MustacheTemplate

Implements a Mustache template class.

Description

The MustacheTemplate class allows you to implement a Mustache template class.

Constructors

Constructs this class and assigns a mustache template.

MustacheTemplate([String? mustacheTemplate])

  • template: String? - mustache template.

Properties

autoVariables

Gets the flag to turn on auto-creation of variables for the Mustache template.

bool get autoVariables

  • returns: bool - flag to turn on auto creation of variables.

Sets the flag to turn on auto creation of variables for the Mustache template.

set autoVariables(bool value)

  • value: bool - flag to turn on auto-creation of variables.

defaultVariables

List with default variables.

Map<String, dynamic> get defaultVariables

  • returns: Map<String, dynamic> - default variables.

initialTokens

List of original mustache tokens.

List<MustacheToken> get initialTokens

originalTokens

Lists the original tokens

List<Token> get originalTokens

  • returns: List<Token> - original tokens

set originalTokens(List<Token> value)

  • value: List<Token> - original tokens

resultTokens

List of processed Mustache tokens.

List<MustacheToken> get resultTokens

Instance methods

clear

Cleans up this calculator.

void clear()

createVariables

Populates the specified variables list with variables obtained from a parsed Mustache template.

void createVariables(Map<String, dynamic>? variables)

  • variables: Map<String, dynamic>? - List of variables to be populated.

evaluate

Evaluates this Mustache template using default variables.

String? evaluate()

  • returns: String? - evaluated template.

evaluateWithVariables

Evaluates this Mustache using specified variables.

String? evaluateWithVariables(Map<String, dynamic>? variables)

  • variables: Map<String, dynamic>? - collection of variables.
  • returns: String? - evaluated template

getVariable

Gets a variable value from the collection of variables.

dynamic getVariable(Map<String, dynamic>? variables, String? name)

  • variables: Map<String, dynamic>? - collection of variables.
  • name: String? - variable name to get.
  • returns: dynamic - variable value or undefined.