用于Rails 3.1应用程序的JST未定义 [英] JST undefined for rails 3.1 application
问题描述
关于资产管道和javascript模板的大多数rails 3.1教程使我相信资产管道将接收任何* .jst文件并将它们拍成* .js文件可用的JST变量.但是,当我尝试加载* .jst模板时,我目前遇到以下错误:
Uncaught ReferenceError: JST is not defined
有指针吗?
如果您在app/assets/application.js
文件中正确包含了javascript模板项,则可以通过资产管道将其包含进来,从而设置JST变量:>
//= require templates/your_template.jst
然后在相应的Rails视图中包含javascript模板(使用haml):
- content_for :javascripts do
= javascript_include_tag "templates/your_template"
Most rails 3.1 tutorials regarding the asset pipeline and javascript templating lead me to believe that the asset pipeline will pick up any *.jst files and slap them into a JST variable that's available to your *.js files. However, I'm currently stumped with the following error when I try to load a *.jst template:
Uncaught ReferenceError: JST is not defined
Any pointers?
The JST variable seems to get set if you correctly include the javascript template items in your app/assets/application.js
file so they can be included via the asset pipeline:
//= require templates/your_template.jst
Then include the javascript template in your corresponding rails views (using haml):
- content_for :javascripts do
= javascript_include_tag "templates/your_template"
这篇关于用于Rails 3.1应用程序的JST未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!