lua-CodeGen
a template engine

Perfection is achieved, not when there is nothing more to add,
but when there is nothing left to take away.
— Antoine de Saint-Exupéry

Overview

lua-CodeGen is a "safe" template engine.

lua-CodeGen enforces a strict Model-View separation. Only 4 primitives are supplied :

  • attribute reference,
  • template include,
  • conditional include,
  • and template application (i.e., map operation).

lua-CodeGen allows to split template in small chunk, and encourages the reuse of them by inheritance.

Each chunk of template is like a rule of a grammar for an unparser generator.

lua-CodeGen is not dedicated to HTML, it could generate any kind of textual code.

References

the Terence Parr's articles :

Note : lua-CodeGen is not a port of Terence Parr's StringTemplate.

Status

lua-CodeGen is in beta stage.

It's developed for Lua 5.1, 5.2 & 5.3.

Download

lua-CodeGen source can be downloaded from GitHub.

Installation

Two variants are available, a pure Lua without dependency and a LPeg based.

lua-CodeGen is available via LuaRocks:

luarocks install lua-codegen
# luarocks install lua-codegen-lpeg

or manually, with:

make install.lua
# make install.lpeg

Test

The test suite requires the module lua-TestMore.

make test.lua
# make test.lpeg

Copyright and License

Copyright © 2010-2014 François Perrad ohloh profile for François Perrad View François Perrad's profile on LinkedIn

This library is licensed under the terms of the MIT/X11 license, like Lua itself.