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

=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 the image
so i get this error

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

How to solve it?

+4
source share
2 answers

You are not correctly displaying the code for the indentation problem in space ... Line numbers will also 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)})';") 

The second line is indented with the same number of intervals that you use in the rest of your temple, while perhaps you have one line (the number in the error is not shown) 2 times as many indents.

+1
source

This is probably not a direct answer to the OP question, but I ran into this error because the first few lines of my HAML were only indented with one space, and then it came across 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 indented, and then it provides this in everything.

+5
source

Source: https://habr.com/ru/post/1341450/


All Articles