Implementation of the mustache logic-less templates in Lua
Lua HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
tests
.gitignore
LICENSE
README.md
example.lua
mostacho.lua
tests.lua

README.md

mustache implementation in Lua

This is a simple implementation of Mustache in Lua.

See [http://mustache.github.com/mustache.5.html] for details on mustache.

How to use

Mostacho does not use Lua modules but closures. You can use Mostacho like so:

local mostacho = require 'mostacho'

local template = [[ This is {{name}}. ]]
local model = { name = 'Mostacho' }

local rendered, err = mostacho.render(model, template)

if rendered == nil then
  error(err)
else
  print(rendered)
end

Goals

  • to be fast.
  • and to be fully compatible with mustache.
  • no external dependencies.
  • maybe I want to compile templates in the future (to avoid parsing them again and again).

Non goals

The mustache processor won't be implemented in the near term.

Features

Errors in templates (unclosed sections, missing end tags) are reported with line numbers.

Status

I'm working on it as a hobby project, no hurries.

All tags from mustache are implemented. This includes:

  • '{{'
  • '{{{'
  • '{{='
  • '{{!'
  • '{{#' '/}}'
  • '{{^' '/}}'

License

Mostacho is released under the MIT License

Mostacho is copyrighted (C) 2012 by Antonio Vieiro (antonio#antonioshome.net)