我正在使用Coffeescript template在我的 Rails 3.1 应用程序中,所以在我的 app/assets/javascripts/post.js.coffee 文件中,我有类似的内容:
$('#post').html JST['templates/posts/show'] post: post
其中 post 是一个 JSON 对象。模板位于 app/assets/javascripts/templates/posts/show
现在我也使用 jquery_ujs 来响应 PostsController#create 并希望使用 app/views/posts/show.js.erb 来呈现响应。在 show.js.erb 中,我想使用上面的模板。我该怎么做呢?谢谢。
最佳答案
看起来像https://github.com/markbates/coffeebeans可能就是您正在寻找的。p>
关于jquery - 如何在 jquery_ujs 响应中的 Javascript ERB 模板中调用 Coffeescript 模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7616414/