What happens with Rails indentation in HTML output?

I am writing code to represent Rails in TextMate (using the standard indentation of the second standard). Whenever I look at the output of my web pages (View Source), the HTML brackets always seem like weird indents. For example, my application.html.erb looks like this:

<!DOCTYPE html> <html> <head> <title>Rainleader</title> <%= stylesheet_link_tag :all %> <%= javascript_include_tag :all %> <%= csrf_meta_tag %> </head> <body> <div id="outer"> <div class="contentwidth main"> <%= render 'layouts/header' %> </div> <%= yield %> </body> </html> 

And its partial rendering (_header.html.erb) looks like this:

 <div class="logo"> <h1><a href="index.html">minimal.</a></h1> </div><!-- end logo --> 

But in the excerpt of the HTML output, there are brackets with the wrong indentation (see my notes in the code below):

 <body> <div id="outer"> <div class="contentwidth main"> <div class="logo"> <<<Why is this so far to the right? <h1><a href="index.html">minimal.</a></h1> <<<Why is this so far to the left? </div><!-- end logo --> 

What's going on here? If my call to the _header.html.erb particle in application.html.erb is indented by four spaces, does the code need to be indented in partial with at least the same amount so that it is set correctly?

+4
source share
1 answer

The first partial line is indented as <%= render 'layouts/header' %> in application.html.erb. But all other lines of code do not recede further, are aligned to the left, as they are in partial. This overheard me too, which is part of why I started using haml.

+3
source

All Articles