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 stu开发者_运维知识库dio 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?
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
I use jQuery.get to load templates I store in html files.
http://encosia.com/using-external-templates-with-jquery-templates/
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.
精彩评论