Shabini Rajadas Shabini Rajadas - 28 days ago 9
Ruby Question

Double Quotation marks for html classes

When using Rubocop, they specify to use single quotation marks rather than double quotation in possible places other than interpolation. So what about the views of a rails app. The classes in the views are written as follows,

<div class="row-fluid">
</div>


Should this also be changed to single quotations? Do that have any performance change? I just want to know why does Rubocop prefer to use single quotation over double quotation.

Answer

TL;DR

  1. Rubocop does not care about views.
  2. HTML is not Ruby, thus it does not even make sense to follow Ruby conventions in HTML.

Should this also be changed to single quotations?

Rubocop does not check views, so it's up to your preferences.

I just want to know why does Rubocop prefer to use single quotation over double quotation.

Today there is no performance difference when using single/double quotes.

I think it is just a matter of taste. I prefer to use single quotes if there is no need in double ones (interpolation). And it occurs to be the opinion of the majority of active members of Ruby community.