According to the docs, here’s how the pluralize function works now:
{{ "cat" | pluralize }}
Can I make it such that it only pluralize if a number passed along with it is greater than one. That is:
{{ "cat" 1 | pluralize }} -> cat
but
{{ "cat" 3 | pluralize }} -> cats
Yes, but not with the syntax you’ve provided above. From where are you pulling this number?
That number is actually meant to be the .ReadingTime
variable. What I really want to achieve is display 1 minute
and not 1 minutes
while I pluralized minutes on the rest of the numbers
I don’t think this is the best use case for pluralize
, really. I’d set up a simple if
statement instead:
{{$rt := .ReadingTime}}
{{ $rt }} minute{{if gt $rt 1}}s{{end}}
1 Like
Thanks @rdwatters . This is a great solution
1 Like