该行比前一行缩进了 2 级。哈姆雷

发布于 2024-10-19 21:38:17 字数 346 浏览 2 评论 0原文

 =image_tag('/images/public_stream_page/overlay_image.png',
:onload=>"document.getElementById('dd_mid_right_box_public').style.background='url(#{stream.asset.url(:normal)})';")

这是我用来显示图像的 haml 代码
所以我收到此错误

The line was indented 2 levels deeper than the previous line.

如何解决?

 =image_tag('/images/public_stream_page/overlay_image.png',
:onload=>"document.getElementById('dd_mid_right_box_public').style.background='url(#{stream.asset.url(:normal)})';")

This is my haml code to display an image
so am getting this error

The line was indented 2 levels deeper than the previous line.

How to resolve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

债姬 2024-10-26 21:38:17

可能不是OP问题的直接答案,但我遇到了这个错误,因为我的HAML的前几行仅缩进一个空格,然后它遇到了使用两个空格缩进的文档部分。显然,HAML 处理器使用前几行来计算缩进中有多少空格,然后在整个过程中强制执行。

Probably not the direct answer to OP's question, but I ran into this error because the first few lines of my HAML were only indented by one space, and then it ran into a section of the document that was indented using two spaces. Apparently the HAML processor uses the first couple of lines to figure out how many spaces are in an indent, and then it enforces that throughout.

孤独患者 2024-10-26 21:38:17

对于与空格缩进相关的问题,您没有以正确的方式显示代码......
行号也会有所帮助。
您应该有这样的内容:

- if stream.asset? 
  =image_tag('/images/public_stream_page/overlay_image.png',:onload=>"document.getElementById('dd_mid_right_box_public').style.background='url(#{stream.asset.url(:normal)})';") 

第二行缩进的间距与您在模板的其余部分中使用的间距相同,而也许您有一行(错误中的数字未显示)缩进了 2 倍。

You're not displaying the code in a correct way for a problem that relates to space indentation...
Also line numbers would help.
You should have something like this:

- if stream.asset? 
  =image_tag('/images/public_stream_page/overlay_image.png',:onload=>"document.getElementById('dd_mid_right_box_public').style.background='url(#{stream.asset.url(:normal)})';") 

With the second line indented with the same number of spacing you use in the rest of your templeate, while perhaps you have one line (number in the error not shown) 2 times more indented.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文