daly88 / lutem

a lua template engine like a famous python template engine jinja2
35 stars 10 forks source link

Welcome

lutem (short for LUa TEMplate engine) is a template render engine like jinja2(a famous template engine written in Python) It's used for auto code generation, dynamic html page generation or other kinds of dynamic text generation

Template Syntax

The syntax is almost the same with jinja2 or Django template,

Loop generate:

{% for k in mp %} ... --this area would be repeated {% endfor %}

variable replacement: {{ variable/raw }} variable example: {{ xxx }} {{ tbl.v }} special raw: {{ '{{' }}

Template Inheritance

child template inheritance by parent template: {% extends abc.tmpl %}

Declare block: {% block blockname %} ... {% endblock %}

The child template will overwrite the parent's block content if correspond block name declared in child template

Example

See the test.lua and test.tmpl