开发者

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

开发者 https://www.devze.com 2023-02-13 10:03 出处:网络
=image_tag(\'/images/public_stream_page/overlay_image.png\', :onload=>\"document.getElementById(\'dd_mid_right_box_public\').style.background=\'url(#{stream.asset.url(:normal)})\';\")
 =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 resol开发者_StackOverflow社区ve it?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消