htmlruby-on-railstwitter-bootstraphigh-voltage

Rails generates unwanted whitespace between partials


I'm developing a Rails application using bootstrap-sass and high_voltage.

I have a navbar partial in views/application/_navbar.html.erb which I'm rendering in the application.html.erb layout view. This, however, causes a  to appear between the navbar and the current view, which breaks my layout. This occurs in any view in the application.

Relevant code in application.html.erb:

<body>
  <%= render 'navbar' %>
  <%= yield %>
  <%= render 'footer' %>
</body>

The navbar is just a default Bootstrap 3.3.7 navbar.

I've tried to remove the whitespace between the render calls, as follows:

<body><%= render 'navbar' %><%= yield %><%= render 'footer' %></body>

but to no avail.

Any help is greatly appreciated.

Edit: screenshot of the Chrome devtools

Screengrab


Solution

  • The workaround I'm using now is to just strip the space from the page using javascript (jQuery in my case):

    $('body').html($('body').html().replace(/\uFEFF/, ''));