Search code examples
ruby-on-railsclassdelimiternumber-with-delimiter

How to add a class to delimiter using rails?


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?


Solution

  • 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) %>