Yatla: Yet Another Templating Language (Again!)

This is my first attempt at a type-inferring templating engine. Designed to be a simplified alternative to Jinja2. This project is essentially an interpreter, more on this to come. For now, I’ve pasted part of the README from GitHub into this file.

Source code available here: https://github.com/eugene-prout/yatla

Sample Template

This sample template gives a whirlwind tour of YATLA’s functionality.

This a sample template.

This line contains a {{ slot }}.

Slots can also contain mathematical expressions: {{ 3 + factor * 7 }}.
With full support for operator precedence: {{ (3 + factor) * 7 }}.

Foreach loops are also valid. For example:

This is the {{ factor }} times table:
{{ foreach num in num_list }}
    {{ factor }} * {{ num }} = {{ factor * num }}
{{ endforeach }}

There is also a standard library of mathematical functions.
Comparing {{ factor }} and {{ num }}, the largest is {{ Maximum(factor, num) }} and the smallest is {{ Minimum(factor, num) }}.
{{ RoundUp(15, 2) }} = 16, and {{ RoundDown(15, 2) }} = 14. 

From the template above, YATLA will identify the parameters in the template, and infer their types:

  • slot: string or number
  • factor: number
  • num: number
  • num_list: number array