Rails3 ERB 语法需要注释掉的 ERB 块
从 Rails 2.3.x 到 Rails 3.0.7 需要更改 ERB 语法,但我不明白。
我收到一个 SyntaxError (意外的 kEND ),如果我在“意外的” kEND 之前添加以下注释行,则可以使错误消失:
# %><%
这对我来说没有意义,而且修复方法很难看。我做错了什么?
这是完整的部分模板代码,可以通过删除第 19 行来切换错误: http://pastie.org/1881607
更新:我从 ERB 语法更改为 HAML 语法,以完全避免这种情况并拥有更易读的代码。
但是,我认为原因是应用程序布局中包含的其他模板文件中存在 ERB 弃用警告。我相信,修复 ERB 弃用警告就可以解决这个问题。
Going from Rails 2.3.x to Rails 3.0.7 requires a change in ERB syntax that I just don't get.
I am getting a SyntaxError ( unexpected kEND ) and I can make the error go away if I add the following commented-out line before the 'unexpected' kEND:
# %><%
This doesn't make sense to me and the fix is ugly. What am I doing wrong?
Here is the complete partial template code, and the error can be toggled by removing line # 19: http://pastie.org/1881607
UPDATE: I changed from ERB to HAML syntax to avoid this completely and have more readable code.
However, I believe the cause was ERB deprecation warnings in other template files included in application layout. Fixing the ERB deprecation warnings, I believe, would have fixed this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[我对上述实际问题的更新的重复]
我认为原因是应用程序布局中包含的其他模板文件中的 ERB 弃用警告。我相信,修复 ERB 弃用警告就可以解决这个问题。
[ a duplicate of my update to the actual question above ]
I believe the cause was ERB deprecation warnings in other template files included in application layout. Fixing the ERB deprecation warnings, I believe, would have fixed this problem.