Julien
Julien

Reputation: 91

yield in Ruby on Rails seems to add extra space when rendering

I've got a problem with layouts and yield. When I follow the guides, I got extra space before the p tag. When I inspect the code with google chrome I got something like:

"
"

between the body and p tags. I type the same code as on the guide but it is not working, did I miss something?

Code for layout:

<html>
  <head>
    <title>Title</title>
  </head>
  <body>
  <%= yield %>
  </body>
</html>

and code for view:

<p>Hello, Rails!</p>

Upvotes: 2

Views: 1021

Answers (2)

Julien
Julien

Reputation: 91

Ok, I founded the problem. It was the UTF8 encoding. In Notepad++, You have to choose to encode in UTF8 but without 'BOM', if you choose only UTF8, you get that extra character which add space.

Thanks!

Upvotes: 6

fl00r
fl00r

Reputation: 83680

You can use minus sign:

<%= yield -%>

to prevent extra space after

Upvotes: 2

Related Questions