使用 & 符号视图渲染预编译的 nunjucks (browserify+nunjucksify)

Render precompilled nunjucks (browserify+nunjucksify) with ampersand-view

正在尝试在 ampersand-view.

中呈现 browserify+nunjucksify-ed 预编译模板

这按预期工作:

var tpl = require('app1/template-1.nunj');
console.log(tpl.render({name: 'flemming', isDancing: 'perhaps'}))

这不是:

var MainView = View.extend({
    template: tpl.render,
    bindings: {
        'model.name': '[data-hook=name]'
    }
});

我得到的错误是

Uncaught TypeError: Cannot read property 'dev' of undefined

AFAIK,这意味着 nunjucks 的 this 是错误的。 Ampersand-view 将自己设置为渲染函数的 this,掩盖了 nunjucks 期望的 this

有什么解决办法吗?

忽略这个问题,我要离开以防其他人遇到同样的问题。

问题不存在,因为 nunjucks 需要在我们 set/pass 将模板呈现到视图之前渲染模板。这样第一次渲染将填充所有非模型(静态)道具,例如翻译等,然后视图处理所有模型道具。

...我觉得。