Trimou is a Mustache implementation written in Java. Helpers API inspired by Handlebars.js is also supported. The goal is to provide a simple to use and easy to extend templating engine for any Java SE or Java EE application.
There are some ready-to-use extensions which provide integration with CDI, Servlets, PrettyTime, HtmlCompressor, google-gson, Spring MVC and Dropwizard.
All the artifacts are available in the Maven Central Repository:
<dependency>
<groupId>org.trimou</groupId>
<artifactId>trimou-core</artifactId>
<version>1.8.2.Final</version>
</dependency>
And now use the MustacheEngine
to compile a Mustache
template and render the output:
// We don't configure anything - use sensible defaults
MustacheEngine engine = MustacheEngineBuilder.newBuilder().build();
// We provide the template contents - no caching and no template locators used
Mustache mustache = engine.compileMustache("hello", "Hello {{this}}!");
// Renders "Hello world!"
System.out.println(mustache.render("world"));
- a really simple example
- a little bit more complex web application example.
Simply run:
$ mvn clean install