I'm using Rails 4 with Haml 4.0.5 I'm trying to add plural when products is greater than one by:
%span>
product
%span#results_plural<
- if @products.count > 1
s
Why is this resulting in:
product s
I'm using Rails 4 with Haml 4.0.5 I'm trying to add plural when products is greater than one by:
%span>
product
%span#results_plural<
- if @products.count > 1
s
Why is this resulting in:
product s
A simpler way might be to use interpolation. If you’re only using the inner span so you can add the whitespace operator to it (i.e. you don’t really need it) you could do:
%span product#{'s' if @products.count > 1}
In Rails you would be better using the pluralize
method, something like:
$span= pluralize(@products.count, 'product')
You can do this
%span{id: "results_#{pluralize(@products.count, 'plural')}"}
The reason why your s is appearing on a different line is probably due to your indentation.