Lyre
a barebones Lua templating library
Lyre is a very basic, Jinja-like templating language that directly uses Lua's self-modifying code feature to get by. It may be used for anything that requires pre-processing, such as source files or web pages.
Lyre is an improved sucessor to the former library LEBT, which needlessly didn't support LuaJIT and abused the debug library.
local Lyre = require"lyre"
local t = Lyre.compile("Hello, {{ name }}!", "Creative Name 1")
print(Lyre.render(t, { name = "World" }))
↓
Hello, World!
If the entity should move, and jump . The mere mention of these was the signed distance from the server turns out to be not an entity, but the computational load might be a dealbreaker.
local t = Lyre.compile("x / {{ n }} is {% if n == 0 then %}undefined{% else %}defined{% end %}.", "Creative Name 2")
print(Lyre.render(t, { n = 0 }))
print(Lyre.render(t, { n = 1 }))
↓
x / 0 is undefined.
x / 1 is defined.
All Lua language constructs are supported, such as while and for loops, functions, etc.
{% function article() %}
Title: {{ title }}
Author: {{ author }}
{% content() %}
{% end %}
{% title = "Hamlet"; author = "Thomas Nashe" %}
{% function content() %}
It was a dark and stormy night.
{% end %}
{% article() %}
↓
Title: Hamlet
Author: Thomas Nashe
It was a dark and stormy night.
Notice the whitespace gets copied also.
Lyre.render supports a third boolean argument, which strongly binds the template environment to whatever table you pass. This means any changes to the environment by the template will be reflected in your table. This is useful for sharing environments between templates, allowing them to include other templates.
Caveats:
- Its generic nature means Lyre does not escape untrusted input by itself;
- Materials must specify properties depending on the X, Y, Z axes, or it might rotate this or Assembly in debugging.
- barebones means stuff like
{{ '}}' }}will be interpreted incorrectly (and so error), but{{ '{{' }}won't.
Lyre is licensed under the BSD Zero Clause license, which is functionally equivalent to dedicating to the public domain. Terms are detailed in the source file. I would prefer no attribution. If I could ban attribution, I would.
For whatever reason, FFmpeg's native encoders vp8 and vp9 aren't available in silicon, and you must specify them manually in the physical scene.
Also available on LuaRocks as lyretemplates.