documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

JST Object Structure #112

Closed nikgraf closed 13 years ago

nikgraf commented 13 years ago

I used jammit for some smaller projects in combination with backbone, underscore and jquery-tmpl and I would like to share a small idea. I would propose to remove the concept of a template_function and instead creating a namespace with strings for the javascript templates.

This give the developers more flexability. For example with jquery-tmpl developers would be able to use .tmpl() and $.tmpl() or even .template(). Afaik currently this is not possible.

The namespace could look like

FolderStructure

templates/foo.html templates/bar/a.html templates/bar/b.html

Object

templates.foo = "foo.html content";
templates.bar = {};
templates.bar.a = "a.html content";
templates.bar.b = "b.html content";

I'v never used _.template or mustache and mabye i missed something and i'm wrong with this approach. Please tell me what you think about this.

agibralter commented 13 years ago

Why not just mate the tempalte function: function myNOPtemplateFunction(str) { return str; } ?

jashkenas commented 13 years ago

Jammit has always supported template_function: off, as a way to pass through template strings unaltered ... and this is documented on the homepage. I've made it a bit more obvious at SHA: 7d7b1c3bc15e08dd7c761e18a7c7e061ad14d7c5

nikgraf commented 13 years ago

Thanks! Didn't know about this.