All Projects → dannote → lua-template

dannote / lua-template

Licence: MIT license
The simplest Lua template engine

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to lua-template

Gotemplatebenchmark
comparing the performance of different template engines
Stars: ✭ 180 (+445.45%)
Mutual labels:  template-engine
Jte
jte is a secure and lightweight template engine for Java.
Stars: ✭ 228 (+590.91%)
Mutual labels:  template-engine
Jade
Jade.go - pug template engine for Go (golang)
Stars: ✭ 251 (+660.61%)
Mutual labels:  template-engine
Elefant
Elefant, the refreshingly simple PHP CMS and web framework.
Stars: ✭ 188 (+469.7%)
Mutual labels:  template-engine
Fatfree
A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
Stars: ✭ 2,504 (+7487.88%)
Mutual labels:  template-engine
Himl
HTML-based Indented Markup Language for Ruby
Stars: ✭ 236 (+615.15%)
Mutual labels:  template-engine
Express Es6 Template Engine
Rendering engine for Express that uses ES6 javascript string templates as syntax.
Stars: ✭ 175 (+430.3%)
Mutual labels:  template-engine
picocog
A tiny code generation library (< 8 KB) written in Java, useful for any purpose, but ideal for JSR-269
Stars: ✭ 82 (+148.48%)
Mutual labels:  template-engine
Flexml
🚀基于Litho的Android高性能动态业务容器。
Stars: ✭ 225 (+581.82%)
Mutual labels:  template-engine
Sailfish
Simple, small, and extremely fast template engine for Rust
Stars: ✭ 242 (+633.33%)
Mutual labels:  template-engine
Yarte
Yarte stands for Yet Another Rust Template Engine
Stars: ✭ 189 (+472.73%)
Mutual labels:  template-engine
Ructe
Rust Compiled Templates with static-file handling
Stars: ✭ 206 (+524.24%)
Mutual labels:  template-engine
Eta
Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
Stars: ✭ 233 (+606.06%)
Mutual labels:  template-engine
Thymeleaf
Thymeleaf is a modern server-side Java template engine for both web and standalone environments.
Stars: ✭ 2,251 (+6721.21%)
Mutual labels:  template-engine
sempare-delphi-template-engine
Sempare Template Engine for Delphi allows for flexible dynamic text generation. It can be used for generating email, html, source code, xml, configuration, etc.
Stars: ✭ 79 (+139.39%)
Mutual labels:  template-engine
Microconfig
Modern tool for microservice configuration management
Stars: ✭ 180 (+445.45%)
Mutual labels:  template-engine
Pupa
Simple micro templating
Stars: ✭ 231 (+600%)
Mutual labels:  template-engine
liquid
A Python engine for the Liquid template language.
Stars: ✭ 40 (+21.21%)
Mutual labels:  template-engine
abell-renderer
A template engine that lets you write variables, loops, and conditions in HTML using JavaScript Syntax.
Stars: ✭ 42 (+27.27%)
Mutual labels:  template-engine
Sodajs
Light weight but powerful template engine for JavaScript
Stars: ✭ 240 (+627.27%)
Mutual labels:  template-engine

lua-template

The simplest Lua HTML template engine in just a few lines of code

Installation

luarocks install template

Compiling templates

Templates can be compiled by either running

templatec template.tpl -o template.lua

nor by passing a string to template.compile.

Syntax

In short, Lua expressions must be included between percent signs and Lua statements must be placed beetween question marks.

Variables and expressions

<a href="page-<%page + 2%>"><%next%></a>

Variables and expressions without HTML escaping

<body><%= content%></body>

Loops

<ul>
<? for i = 1, 3 do ?>
  <li>item #<%i%></li>
<? end ?> 
</ul>

Conditional

<? if 1 > 2 then ?>
Impossible!
<? else ?>
That's right!
<? end ?>

Template inclusion

Templates are compiled to a general Lua file and hence can be loaded by require statement:

<html>
  <script><%= require "scripts" %></script>
  <style><%= require "styles" %></style>
</html>

Evaluating templates

template.print takes three arguments: template function, a table with variables passed to the template and optionally a callback function, which handles string printing (print is used by default).

Compressing templates

template.compile has an optional minify argument and templatec has -m option.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].