Skip to content
spullara edited this page Dec 6, 2010 · 7 revisions

To ask questions or join in the discussion, there is a "Google group":https://groups.google.com/group/mustachejava.

Mustache.java is a Java 6 implementation of the "mustache language":http://mustache.github.com/. It supports all the base functionality and ignores some of the things like pragmas. Here are some interesting properties of this implementation:

compiled down to Java code

very simple to implement the backing code

highly concurrent execution

reloadable at runtime during development

Here is the code required to compile and execute hello, world:

public class HelloWorld { String hello = "Hello"; String world() {return "world";}

public static void main(String[] args) throws MustacheException, IOException { FutureWriter writer = new FutureWriter(new OutputStreamWriter(System.out)); new MustacheCompiler().compile(new StringReader("{{hello}}, {{world}}!")).execute(writer, new Scope(new HelloWorld())); writer.flush(); FutureWriter.shutdown(); } }

The simplicity of implementation of the backing code is that mustache.java cares very little about things like public/private, you can make it whatever you want and it will be able to access your fields and methods. The names need to match up with the names in the mustache templates though you can do things like 'object.subobject' and mustache.java will evaluate them by going through the hierarchy.

Clone this wiki locally