layout | homepage | disable_anchors | description |
---|---|---|---|
full |
true |
true |
Aspect is a compiling template engine for Lua and LuaJIT. |
Aspect is a compiling templating engine for Lua and OpenResty.
The key-features are...
- Well known: The most popular syntax is used - Twig compatible, Jinja/Liquid like.
- Fast: Aspect compiles templates down to plain optimized Lua code. Moreover, Lua code compiles into bytecode - the fastest representation of a template.
- Secure: Aspect has a sandbox mode to evaluate all template code. This allows Aspect to be used as a template language for applications where users may modify the template design.
- Flexible: Aspect is powered by a flexible lexer and parser. This allows the developer to define their own custom tags, filters, functions and operators, and to create their own DSL.
- Supports lua 5.1/5.2/5.3 and luajit 2.0/2.1 (with OpenResty)
- Has console renderer.
- No dependencies. Pure Lua.
- List of all features
<!DOCTYPE html>
<html>
<head>
{% block head %}
<title>{{ page.title }}</title>
{% endblock %}
</head>
<body>
{% block content %}
<ul id="navigation">
{% for item in navigation %}
<li><a href="{{ item.href }}">
{{- item.caption|escape -}}
</a></li>
{% endfor %}
</ul>
<h1>My Webpage</h1>
{{ page.body }}
{% endblock %}
</body>
</html>
Aspect also has a console tool for rendering data
$ aspect /path/to/data.json /path/to/template.tpl
- Variables
- Expression
- Filters
- Functions
- Named Arguments
- Control Structure
- Comments
- Template Inheritance
- Macros
- Expressions
- Operators
- Whitespace control
- HTML Escaping
- set — assign values to variables
- do
- if, elseif, elif, else — conditional statement
- for, else, break — loop over each item in a sequence.
- macro, import, from
- include — includes a template and returns the rendered content
- extends, block, use - template inheritance (read more)
- autoescape
- verbatim
- with
- apply (todo)
- embed (todo)