-
-
Notifications
You must be signed in to change notification settings - Fork 265
Description
Note: I am not a user of liquidjs but found this while working on dotliquid/dotliquid#390
Shopify is working on updating their docs (see Shopify/liquid#1403 and the future docs at https://ericfromcanada.github.io/liquid/filters/capitalize/) that notes that capitalize actually lower cases everything. So mcDonald becomes Mcdonald! LiquidJS does not implement this way (IMHO is a more sensible version).
I tested Ruby liquid on my server -
{
"template": "{{ name | capitalize }}",
"data": {
"name": "John G. Chalmers-Smith"
}
}
Result: John g. chalmers-smith
if I add a space before the name, it will be all lowercase.
FYI - In Rails, the equivalent to this is named upcase_first. See https://glaucocustodio.github.io/2016/05/19/rails-5-new-upcase-first-method/ and https://stackoverflow.com/questions/3724913/how-to-capitalize-the-first-letter-in-a-string-in-ruby