DoubleCurly templating syntax

Expressions

  • {{expression}}
  • {{expression ` format}}

format is a .NET format string.

Example:

Data:

context = new FlexContext(new {product="iPhone X", price=999});

Template:

The price of {{product}} is {{price ` $0.00}}

Result:

The price of iPhone X is $999.00

Loops

  • {{foreach varName in collection}}
  • {{end}} (ends the loop block)
Example:
{{foreach product in products}}
- Product {{product.name}} costs {{product.price ` $0.00}}
{{end}}

To use a for-loop with a counter, foreach can be used with the range operator:

{{foreach i in 1...10}}#{{i}} {{end}}

Output:

#1 #2 #3 #4 #5 #6 #7 #8 #9 #10

Conditionals

  • {{if condition}}
  • {{elseif}}
  • {{else}}
  • {{end}}