firebird
firebird

Reputation: 3511

backbone: better way to template?

I want to use the features of the IDE to build the templates therefore I avoid using inline templates. The other option is to have the templates in script tags but doing this causes Visual studio to stop giving intellisense for the template html.

I tried to store the template in a div tag and convert it into a script tag before the backbone templated it but for some reason it caused the attribute values (ex: href="{{test}}") to be encoded.

Is there a better way to build the template?

Upvotes: 0

Views: 1734

Answers (3)

rakitin
rakitin

Reputation: 2175

I use jQuery.get as above and then append what's returned to the body of the html document. I'm told there are better ways to do it in a related post.

Upvotes: 0

modernzombie
modernzombie

Reputation: 2049

I use jQuery.get to load templates I store in html files.

http://encosia.com/using-external-templates-with-jquery-templates/

Upvotes: 2

Sander
Sander

Reputation: 13421

i put my templates in separate html files, and use require.js to load them with its !text plugin. then there is also the added functionality of the !strip you can use with it

so technically instead of loading html from a script tag, you load if from a separate html file, and thanks to the !strip it does not load the and tags, but only the 's content.

more info on how to use could be seen here: http://requirejs.org/docs/api.html#text

Upvotes: 3

Related Questions