按照handlebars_assets上的说明进行操作后,
我仍然无法让它工作。
我的步骤是:
1) 在 Gemfile 上添加了 gem 'handlebars_assets'
2) 运行捆绑安装
3) 确保 application.js//= requirevendor/handlebars-v2.0.0
4) 也将//= require_tree ./handlebars_templates 添加到 application.js
5)handlebars_templates目录位于app/assets/javascripts下
6)将test.hbs添加到handlebars_templates目录
7) test.hbs 包含 <div>test hbs</div>
8)在我写的backbone.js View 中
template: HandlebarsTemplates['handlebars_template/new_map/infoWindow'](context),
加载浏览器时收到的错误是:
Uncaught ReferenceError: HandlebarsTemplates is not defined
我错过了什么?
最佳答案
确保在安装 handlebars_assets
gem 后重新启动 Rails 服务器!
关于javascript - Handlebars 模板未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28744654/