Skip to content

Instantly share code, notes, and snippets.

@parj
Created May 30, 2013 20:03
Show Gist options
  • Save parj/5680695 to your computer and use it in GitHub Desktop.
Save parj/5680695 to your computer and use it in GitHub Desktop.
Sample gist to get mustache.java running in gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.8.12'
}
}
class Feature {
Feature(String description) {
this.description = description;
}
String description;
}
task m << {
HashMap<String, Object> scopes = new HashMap<String, Object>();
scopes.put("name", "Mustache");
scopes.put("feature", new Feature("Perfect!"));
Writer writer = new OutputStreamWriter(System.out);
def mf = new com.github.mustachejava.DefaultMustacheFactory();
def mustache = mf.compile(new StringReader("{{name}}, {{feature.description}}!"), "example");
mustache.execute(writer, scopes);
writer.flush();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment