2

I have added a comma to a large number using the number_with_delimiter call, now I'd like to add a class to the comma.

This is my code to get the commas

= "#{number_with_delimiter(1000, delimiter: ",")}"

I think the code to add the class to the commas should look something like this but its not working.

= "#{number_with_delimiter(1000, delimiter: ",", class:"hello")}"

Any thoughts?

Abby Marsh
  • 31
  • 2
  • I guess `class` is not one of the available options for `number_with_delimiter`. – Pavan Oct 21 '15 at 13:58
  • what do you mean by `add a class to the comma`? Do you want the comma to be wrapped in a HTML element (like a span) having the HTML class 'hello' ? – MrYoshiji Oct 21 '15 at 14:14
  • I am trying to add the class specifically to the comma so I can style it differently than the rest of the numbers. – Abby Marsh Oct 21 '15 at 14:19

1 Answers1

1

Try wrapping each comma in a span tag and add a class to that span. Example:

<%= number_with_delimiter(1000, delimiter: "<span class='hello'>,</span>".html_safe) %>
Sean Huber
  • 3,945
  • 2
  • 26
  • 31