A fast, embedded Lua templating engine that compiles templates directly to Lua code for high-performance rendering.
etlua is an embedded templating engine for Lua that allows developers to mix Lua code with HTML or text templates. It compiles template files directly into Lua functions, providing high-performance rendering while maintaining access to the full Lua language within templates. The engine solves the problem of needing fast, flexible templating in Lua web applications and scripts.
Lua developers building web applications, CLI tools, or any application needing dynamic text generation with templates. Particularly useful for those using frameworks like Lapis or creating Lua-based web services.
Developers choose etlua for its exceptional performance (templates compile to native Lua functions), its simplicity (uses actual Lua syntax instead of a custom language), and its flexibility (full Lua language access within templates). It's lightweight, integrates seamlessly with existing Lua codebases, and offers both high-level and low-level APIs.
Embedded Lua templates
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Templates compile directly to Lua functions for fast rendering, with the README emphasizing caching compiled templates to avoid recompilation overhead.
Supports arbitrary Lua code within <% %> tags, allowing developers to leverage Lua's syntax and libraries without learning a separate template language.
Compile errors show original template positions, not generated code locations, simplifying debugging by pointing directly to source issues as described in the reference.
Custom compilers can be created by extending etlua.Compiler, enabling integration with custom buffers or adding features like debug printing, as shown in the example.
Lacks sandboxing for Lua execution, making it unsafe for rendering templates from untrusted sources without additional security measures implemented by the developer.
Does not provide built-in support for common templating patterns like layout inheritance or partials, requiring manual implementation in Lua code.
Tied exclusively to Lua environments, limiting use in non-Lua projects and relying on Lua's performance and compatibility, which may not suit all deployments.