为什么不“haml --check”?发现这个明显的语法错误
我正在寻找可以帮助我追踪语法错误的 rake 任务,并且我发现了 haml --check
作为双重检查 haml 文件的可能解决方案。不幸的是,当我将这个损坏的示例传递给它时,haml 说语法没问题。
我是否误解了 haml --check
的目的,或者此功能是否未完全实现?
我想我应该提到我正在使用 Haml/Sass 3.0.25 (Classy Cassidy)、rails 3.0.3、ruby 1.9.2p0 和 Mac 10.6.6。
<代码> $ haml --check /tmp/edit.html.haml
语法确定
#/tmp/edit.html.haml - content_for :head do = include_javascripts :aspects #aspect_edit_pane #facebox_header %h4 = @aspect .description = t('contacts', :count =>@aspect_contacts.count)}
最后一个字符(大括号)应该触发语法错误,当模板作为请求的一部分执行时肯定会触发语法错误:
ActionView::Template::Error (compile error /usr/local/app/diaspora/app/views/aspects/edit.html.haml:13: syntax error, unexpected '}', expecting ')'
I was looking for rake tasks that would help me track down syntax errors, and I came across haml --check
as a possible solution for double checking haml files. Unfortunately, when I passed it this broken example, haml says the syntax is OK.
Have I misunderstood the purpose of haml --check
or is this feature not fully implemented?
I suppose I should mention I'm using Haml/Sass 3.0.25 (Classy Cassidy), rails 3.0.3, ruby 1.9.2p0, and Mac 10.6.6.
$ haml --check /tmp/edit.html.haml
Syntax OK
#/tmp/edit.html.haml - content_for :head do = include_javascripts :aspects #aspect_edit_pane #facebox_header %h4 = @aspect .description = t('contacts', :count =>@aspect_contacts.count)}
The last character (curly brace) should trigger a syntax error, it certainly does when the template is executed as part of a request:
ActionView::Template::Error (compile error /usr/local/app/diaspora/app/views/aspects/edit.html.haml:13: syntax error, unexpected '}', expecting ')'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许是因为
-c, --check 只检查语法,不评估。
猜测:它只检查 haml 语法,不评估内联 ruby。
--edit
这可能需要更多的测试,但我让它在简单的 haml 文件上工作:)
理论上:
Haml 打印出预编译的 Ruby 源代码(以及错误消息) end),我们尝试只获取 ruby 部分并检查语法。
Maybe because
-c, --check Just check syntax, don't evaluate.
Guess: it checks just the haml syntax and doesn't evaluate inline ruby.
--edit
This probably needs some more testing but I got it working on simple haml files :)
In theory:
Haml prints out the precompiled Ruby source (and error messages in the end), we try to get just the ruby part and check the syntax.