在 Firefox 中使用 Firebug 调试 CoffeeScript
使用 Rails 3.0.7 时,如何在 Firefox 中使用 firebug 调试 CoffeeScript?
我正在使用 Barista 和 Coffeescript。它工作得很好(一个基本的“警报“你好””正在运行)。
然而,当出现明显错误时......什么也不会发生。如何获得更深入的反馈? :/
这就是我将其添加到我的 erb 文件中的方式:
<%= coffeescript_include_tag "lib/dynamic_menu", "views/tour" %>
这是我的 Coffeescript 安装包含在页面中的内容:
<script src="/javascripts/coffeescript.js" type="text/javascript"></script>
<script src="/coffeescripts/lib/dynamic_menu.coffee" type="text/coffeescript"></script>
<script src="/coffeescripts/views/tour.coffee" type="text/coffeescript"></script>
当我查看 Firebug 时,我可以看到它正在加载这些内容,但它只是说“200 OK”。除此之外,什么也没有发生(因为显然我的代码是错误的......但没有反馈,我怎么知道?:/
How do you debug coffeescript in Firefox w/ firebug when using rails 3.0.7?
I am using Barista and Coffeescript. It works just fine (a basic 'alert "hello"' is running).
However, when there are obviously errors... nothing happens. How can I get more indepth feedback? :/
This is how I add it to my erb file:
<%= coffeescript_include_tag "lib/dynamic_menu", "views/tour" %>
This is what my coffeescript installation is including in the page:
<script src="/javascripts/coffeescript.js" type="text/javascript"></script>
<script src="/coffeescripts/lib/dynamic_menu.coffee" type="text/coffeescript"></script>
<script src="/coffeescripts/views/tour.coffee" type="text/coffeescript"></script>
When I look in Firebug, I can see it loading these, but it just says "200 OK". Other than that, nothing happens (because obviously my code is wrong... but without feedback, how am I supposed to know? :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前没有见过有人使用 Barista 的
coffeescript_include_tag
功能,说实话,我不明白它有什么意义。一旦浏览器为 CoffeeScript 提供本机调试支持(这肯定会到来),这可能会很好,但现在,您最好利用 Barista 透明编译为 JavaScript 的能力。只需使用javascript_include_tag
即可,或者关闭 Barista 的embedded_interpreter
选项。就“如何开始”而言,咖啡师文档目前还不完全清楚,因此您可能需要查看 这篇博文。
如果您使用的是 Mac,我还建议使用 barista_growl (我写的),这样您会变得更好CoffeeScript 编译错误的报告。
(顺便说一句,您看到
200 OK
的原因是.coffee
文件是在初始页面加载后通过 Ajax 加载的。这可能会混淆一些 JavaScript调试工具。)I haven't seen anyone use the
coffeescript_include_tag
feature of Barista before, and honestly, I don't see the point of it. It might be nice once browsers offer native debugging support for CoffeeScript (which is certainly coming), but for now, you're better off taking advantage of Barista's ability to compile to JavaScript transparently. Just use thejavascript_include_tag
instead, or turn off Barista'sembedded_interpreter
option.The Barista docs aren't totally clear as far as "How to Get Started" right now, so you may want to check out this blog post.
I also suggest using barista_growl (which I wrote) if you're on a Mac, so that you get better reporting of CoffeeScript compilation errors.
(The reason you're seeing
200 OK
, by the way, is that the.coffee
files are loaded via Ajax, after the initial page load. That may confuse some JavaScript debugging tools.)