本文介绍了erb在咖啡剧本与路轨3.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的 .coffee
文件中使用一些erb,如下例所示:
I would like to use some erb in my .coffee
files, like the following example
myLatlng: new google.maps.LatLng(<%[email protected] %>, <%[email protected] %>)
我将 locations.js.coffee
重命名为 locations.erb .coffee
但我仍然会收到以下错误
but I still get the following error
Error compiling asset application.js:
ExecJS::ProgramError: Error: Parse error on line 4: Unexpected 'COMPARE'
(in /Users/denisjacquemin/Documents/code/projects/geolog/app/assets/javascripts/locations.erb.coffee)
Served asset /application.js - 500 Internal Server Error
推荐答案
如果你想在 .coffee
yourfilename.js.coffee
,Rails仍然会处理ERB,奇怪的是。
If you want erb in the .coffee
files IN YOUR VIEW folder, leave your file named as yourfilename.js.coffee
, and Rails will still process the ERB, oddly enough.
Heroku,将咖啡栏从您的Gemfile中的资产组中移出。
To make it work in Heroku, move coffee-rails out of the assets group in your Gemfile.
这篇关于erb在咖啡剧本与路轨3.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!