我正在使用 Webpack 设置应用程序并使用 Backbone Marionette 运行前端。我已经设法让应用程序脚本运行[在应用程序模块内的控制器中生成 LayoutView,就像在 AMD/Require 中一样],但我不知道是模板。
过去,我使用过 Underscore 模板,但 webpack 更喜欢 Jade 和 Handlebars。我切换到 Jade,但我的 LayoutView 仍然返回错误:
未捕获的 UndefinedTemplateError:无法呈现模板,因为它为 null 或未定义。
当我控制台注销渲染的 Jade 模板时,我得到:<div class="glossary-container"></div>
这是我的 LayoutView 代码供审查:
Marionette = require 'marionette'
AppLayoutTemplate = (require 'templates/appLayoutTemplate.jade')()
console.log AppLayoutTemplate
class AppLayoutView extends Marionette.LayoutView
initialize: ->
template: AppLayoutTemplate
regions:
glossaryContainer: '.glossary-container'