Friday, 15 January 2010

javascript - Backbone/Marionette JST Templates - No errors but no View shown -



javascript - Backbone/Marionette JST Templates - No errors but no View shown -

i needed move using jst file templates don't have clutter of html templates everywhere.

i building jst file grunt (using grunt-contrib-jst) , creates file "build/templates.js".

below entry there:

this["jst"] = this["jst"] || {}; this["jst"]["build/html/template-1.html"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += ' <script type="text/template" id="template-1">\n <span id="chat_title_1">' +((__t = ( title )) == null ? '' : __t) +'</span>\n <span id="chat_symbol_1">▲</span>\n </script>';}return __p};

i updated backbone.marionette render method per https://github.com/marionettejs/backbone.marionette/wiki/using-jst-templates-with-marionette, asks replace renderer.render method. see alter below:

marionette.renderer = { render: function(template, data){ if (!jst[template]) throw "template '" + template + "' not found!"; homecoming jst[template](data); } };

so have next in view:

app.chatboxview = backbone.marionette.layout.extend({ template: "build/html/template-1.html", ...

the page loads, there no errors or anything, there nil rendering on page, no views, etc.

is there missing or done wrong?

thank you.

solved it... template html files still had <script ....> @ start , end. removing worked.

updated entry illustration in "templates.js":

this["jst"] = this["jst"] || {}; this["jst"]["build/html/template-1.html"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '<span id="chat_title_1">' +((__t = ( title )) == null ? '' : __t) +'</span>\n <span id="chat_symbol_1">▲</span>';}return __p};

javascript templates backbone.js marionette jst

No comments:

Post a Comment