andrewdavey/cassette — pull request #319 by prabirshrestha (2012-10-04 02:41:33+00:00)
Title: JST array for templates

PR for #265

Introduces new classes main one being `JavaScriptArrayHtmlTemplatePipeline`.

```c#
bundles.Add("assets/templates",
b => b.Pipeline = new JavaScriptArrayHtmlTemplatePipeline(this.container, this.settings));
```

output:

```js
window.JST=window.JST || {};
JST["todo/index"]="

\r\n Todo\r\n

";
JST["todo/item"]="

\r\n item\r\n

";
```

If you want to change the variable to something else besides `JST` pass the third parameter.

```c#
new JavaScriptArrayHtmlTemplatePipeline(this.container, this.settings, "templateHashName")
```

Here is an example at how clients can cache the underscore templates.

```js
function buildTemplate(model) {
var template = JST[this.templateName];
if (typeof (template) === 'string') {
template = JST[this.templateName] = _.template(template);
}

return template(model);
}
```