gruntjs/grunt-contrib-jade — pull request #14 by AndreyM (2013-02-08 04:43:55+00:00)
Title: Implemented compilation for client:true and added wrappers for AMD and JST

It is sometimes desired to use Jade templates client-side, e.g. in Backbone apps. Jade compiler supports "client: true" mode, which produces javascript function, which can be called client side.

To use jade templates client-side you have to change extension to .js, and add one of the wrappers: amd or jst. AMD wrapper will create AMD-compatible module in the specified destination file to be used with require.js.

```
jade: {
files: {
'tmp/jst/jade.js': ['test/fixtures/jade.jade']
},
options: {
client: true,
wrapper: "amd"
}
}
```

JST wrapper will extend global JST object with template function. Template name can be processed with `processName(srcFile)`. Compiled template then can be rendered simply by calling `window.JST["templateName"](data)`:

```
jade: {
files: {
'tmp/jst/jade.js': ['test/fixtures/jade.jade']
},
options: {
client: true,
wrapper: "jst",
processName: function(str) { return str.match(/^test\/fixtures\/(.*)\.jade$/)[1]; },
}
}
```