I have a case where I need to use pluralize to properly spell something. However, I need to render the html like so:
<span>1</span> thing
or,
<span>3</span> things
I could write a helper method, but I'm just making sure there isn't something in the box to do this.
Noun. formatting (countable and uncountable, plural formattings) The visual style of a document, including fonts, borders, etc.
Key Point: Pluralize a single letter by adding apostrophe-s. To form the plural of a single letter, italicize the letter and add an apostrophe followed by the unitalicized letter s. Recommended: We called tech support because the printer wasn't printing uppercase B's or lowercase p's.
The easiest way to tell if a noun is a singular noun or a plural noun is to look at how much of something it is referring to. If it is only referring to one person or thing, it is a singular noun. If it is referring to more than one person or thing, it is a plural noun.
This uses the Rails class TextHelper which uses Inflector to do the pluralization if needed.
def pluralize_with_html(count, word)
"<span>#{count}</span> #{TextHelper.pluralize(count, word)}"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With