07 Variables in tag expressions - domain-centric/template_engine GitHub Wiki

A variable is a named container for some type of information (like a number, boolean, string, etc...)

  • Variables are stored as key, value pairs in a dart Map<String, dynamic> where:
    • String=Variable name
    • dynamic=Variable value
  • Variables can be used in an ExpressionTag
  • Initial variable values are passed to the TemplateEngine.render method
  • Variables can be modified during rendering

The variable name identifies the variable and corresponds with the keys in the variable map.

The variable names:

  • are case sensitive
  • must start with a lower case letter, optionally followed by (lower or upper) letters and or digits.
  • conventions: use lowerCamelCase
  • must be unique and does not match a other tag syntax

Variables can be nested. Concatenate variable names separated with dot's to get the variable value of a nested variable name: E.g.: Variable map: {'person': {'name': 'John Doe', 'age',30}} Variable name person.name: refers to the variable value of 'John Doe'

Examples: