A Gradle plugin that compiles templates. This plugin requires LinkedIn Dust.js and uses Rhino to run the Dust compiler.
Add a buildscript dependency on the plugin to pull the artifact for the plugin:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.linkedin:gradle-dustjs-plugin:1.0.0'
}
}
apply plugin: 'dustjs'
dustjs {
source = fileTree('src/main/tl') {
include 'template.tl'
}
dest = 'src/main/webapp/assets/js'
}
This plugin adds the dustjs
task and the implicit cleanDustjs
task.
The dustjs
task compiles the specified Dust .tl files from the source
directory into .js files into the dest
directory.
The basename of the template file is used as the template name. For example, if one of the files to be compiled is template.tl
, then running the plugin is equivalent to the following dustc
invocation:
$ dustc --name=template source/template.tl dest/template.js
The cleanDustjs
task completely deletes the dest
directory.
This plugin makes use of code adapted from Oliver Becker's Gradle LESS plugin and Jonathan Parsons' Play Framework Dust.js plugin.