Created
May 30, 2013 20:03
-
-
Save parj/5680695 to your computer and use it in GitHub Desktop.
Sample gist to get mustache.java running in gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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