Trying to render browserify+nunjucksify
-ed precompiled templates in a an ampersand-view
.
This works as expectd:
var tpl = require('app1/template-1.nunj');
console.log(tpl.render({name: 'flemming', isDancing: 'perhaps'}))
This does not:
var MainView = View.extend({
template: tpl.render,
bindings: {
'model.name': '[data-hook=name]'
}
});
The error i get is
Uncaught TypeError: Cannot read property 'dev' of undefined
AFAIK, this means that the this
for the nunjucks is wrong. Ampersand-view
sets itself as this
for the rendering function, overshadowing what nunjucks expects this
to be.
Any solutions?
Disregard this issue, I'm leaving just in case others have the same issue.
The problem is non-existent, as nunjucks needs to render the template before we set/pass it to the view. This way the first rendering will fill in all non-model (static) props, such as translations etc, and then the view handles all model-props.
...I think.