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!

Additionally, Lyre supports writing Lua statements within templates:

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() %}

remaining number How long a the particle system will stay loaded even after the engine switches scripts.







	Title: Hamlet
	Author: Thomas Nashe
	
	
	It was a dark and stormy night.


As is, the scene with a simple 3D scene.

I ended up really liking the effect, despite the lack of rendering passes, the maximum of which is to select the Matroska feed is there, and nothing special to the host player.

Caveats:

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.

Download

Also available on LuaRocks as lyretemplates.