Search code examples
ruby-on-railsrubyhaml

HAML ActionView::Template::Error SyntaxError: stdin missing indentation


I'm really stuck. I had some code which used to work, but does not on my new branch.

I am getting

ActionView::Template::Error (SyntaxError: [stdin]:79:1: missing indentation):
    1: !!! html
    2: %html
    3:   %head
    4:     %link{rel: 'shortcut icon', href: image_path('analyst-console-favicon.ico')}
    5: 
    6:   %body

My layout file has the following:

!!! html
%html
  %head
    %link{rel: 'shortcut icon', href: image_path('analyst-console-favicon.ico')}

  %body

I did a hexdump and verified that the indentation uses spaces.

If I delete the %link line, then it returns the following HTML:

<!DOCTYPE html>
<html>
<head></head>
<body></body>
</html>

I don't even know what to check might be wrong.


Solution

  • I found that I had comments in a coffee script file which were indented. When I removed the indentation and had the comments flush with the left column of the file it works. It fully works.

    It seems bizarre that having the shortcut icon link toggles whether the indents in the coffee script break the code or not.