Code Tips
Get tips for writing code in Shopify Liquid, HTML, CSS and Javascript.
Remove the last character of a string with Liquid
Sometimes, when manipulating a string or receiving a string from some variable or function, you want to get rid of the string's last character. There might be a period there, or a slash, or some other remnant of a previous operation. In any case, you want to get rid of...
Remove the last character of a string with Liquid
Sometimes, when manipulating a string or receiving a string from some variable or function, you want to get rid of the string's last character. There might be a period there, or a slash, or some other remnant of a previous operation. In any case, you want to get rid of...
Use Liquid to count the number of words in a string
Liquid doesn't come with a way to count how many words a given string contains. But there's a fairly easy way to determine that number with some clever use of Liquid filters. Assume you want to show how many words a blog post has. You would take the content of...
Use Liquid to count the number of words in a string
Liquid doesn't come with a way to count how many words a given string contains. But there's a fairly easy way to determine that number with some clever use of Liquid filters. Assume you want to show how many words a blog post has. You would take the content of...
Using singular and plural forms in theme locale files
That themes can be translated into any language is probably a well-known fact. What's less well-known is that you can set up your translations so that singular and plural word forms are automatically used appropriately. For example, say you have a block on your product detail page where it says...
Using singular and plural forms in theme locale files
That themes can be translated into any language is probably a well-known fact. What's less well-known is that you can set up your translations so that singular and plural word forms are automatically used appropriately. For example, say you have a block on your product detail page where it says...