0

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

Niek
  • 1,464
  • 1
  • 17
  • 27
  • You should inspect the page in the browser and figure out what CSS rules are adding margins/paddings, rails will not "add whitespace" by itself. – m3characters Sep 17 '17 at 11:15
  • @MicaelNussbaumer I know how css works. Here is the outputted HTML since you don't seem to believe me: ` – Niek Sep 17 '17 at 11:18
  • I would check your JS and what you're yielding. What is carousel-wrapper? Try to wrap the yield block into a "container" div and see if it still appears between the nav and the new container – m3characters Sep 17 '17 at 11:27
  • @MicaelNussbaumer Thanks. I'm not sure how JS could effect this problem? The non-breaking space now appears between the starting `
    ` and the beginning of the view partial.
    – Niek Sep 17 '17 at 16:51
  • If you're loading some JS libs/plugins/etc it might be trying to do something with the container and due to some reason adding that text node right before the container it should affect, probably to help with displaying something? I would say it's something like that. – m3characters Sep 17 '17 at 17:18
  • @MicaelNussbaumer I tried viewing the page with Javascript disabled, but that unfortunately did not work. – Niek Sep 18 '17 at 14:28

1 Answers1

0

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/, ''));

Niek
  • 1,464
  • 1
  • 17
  • 27