tiny-mustache icon indicating copy to clipboard operation
tiny-mustache copied to clipboard

:speak_no_evil: The smallest implementation of Mustache template engine. (0.4 KB)

Tiny Mustache

The smallest implementation of Mustache template engine.

Only 436 bytes gzipped.

Usage

mustache("Hello {{name}}!", {name: "world"})
// => Hello world!

Features

  • [x] variables {{escaped}}, {{&unescaped}}, {{{unescaped}}}
  • [x] sections {{#section}}
  • [x] inverted sections {{^inverted}}
  • [x] lambdas {{#lambda}}
  • [x] comments {{!comment}}
  • [x] partials {{>partial}}
  • [x] variables dot notation {{obj.prop}}
  • [x] tests

Not implemented

  • set delimiter {{=<% %>=}}

Browser support

This library works in every modern browser. To use it in IE you will need a polyfill for Object.assign().