An SBT plugin to compile Dustjs templates.
This plugin is a continuation of play-dustjs built for sbt-web and Play 2.3.x.
Add the sbt plugin to your project/plugins.sbt
file:
addSbtPlugin("com.jmparsons.sbt" % "sbt-dustjs-linkedin" % "1.0.3")
Include the core dust file using webjars:
libraryDependencies ++= Seq(
"org.webjars" % "dustjs-linkedin" % "2.4.0-1"
)
The webjars path will look like this:
<script src="@routes.Assets.at("lib/dustjs-linkedin/dust-core.js")"></script>
Or include the dust core file manually from LinkedIn Dustjs.
<script src="@routes.Assets.at("javascripts/dust-core-2.4.0.js")"></script>
Place your template .tl files anywhere inside of the app/assets/
it will be available in the corresponding directory. If placed into app/assets/templates/
the output would be target/web/public/main/templates/
.
Pull in the generated javascript template file:
<script src="@routes.Assets.at("templates/example.js")"></script>
Example requirejs loading config:
require.config
paths:
dust: "../lib/dustjs-linkedin/dust-core"
shim:
"../templates/example":
deps: ["dust"]
require ["dust", "../templates/example"], () ->
Render the template:
$(function() {
$.get('@routes.Application.data', function(data) {
console.log('data = ' + JSON.stringify(data));
dust.render('example', data, function(err, out) {
$('#dust_pan').html(err ? err : out);
});
});
});
Example project with RequireJS using play-dustjs: https://github.com/jmparsons/play-scala-backbone-todo
1.0.3 - August 5, 2014
- Add Windows compatibility
1.0.2 - July 9, 2014
- Reverted away from transpiler to have more control
- Fixed source file mapping bug
1.0.1 - July 7, 2014
- Updated to dustjs-linked version 2.4.0
- Added webjar as npm module
- Removed dependency for npm installed dust
1.0.0 - May 19, 2014
- Inital commit
- Added tests using sbt scripted