mustache implementation for scala.
Scala Java
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


mustache.scala is an implementation of mustache for Scala. It does not at present support custom delimiters.

To render a template, a Mustache object must first be instantiated. This takes a, which has many convenience methods for reading files, strings, etc.

import org.monkey.mustache._
val mustache = new Mustache(io.Source.fromString(
  "{{helloworld}} {{#truefalse}}yes?{{/truefalse}}" + 
  "{{#falsetrue}}grr{{/falsetrue}}" +

Once the template is instantiated, it is rendered with a Dictionary. Dictionary provides a builder to create dictionaries:

val d = Dictionary()
  .data("helloworld", "hello, world!")
  .bool("truefalse", true)
      .data("v2", "iter0"))
      .data("v2", "iter1"))

The string is then rendered with Mustache.apply

scala> mustache(d)
res4: String = hello, world! yes?iter0iter1

The mustache AST is available to the application developer, so she may provider her own interpreter. This is useful, for example, to give the template access to an object graph directly instead of the default Dictionary implementation.


mustache.scala uses ANTLR for parsing. This requires source files to be generated. Thus, the slightly modified sbt routine is necessary:

$ sbt update
$ sbt compile-antlr

This only needs to be run initially, and whenever the grammar has changed (src/main/antlr/Mustache.g).

maven / sbt

mustache.scala is published to the maven repo at To use with sbt, add the following lines:

val monkeyRepo = "" at ""
val mustache = "org.monkey" % "mustache" % "1.0.3"