String
String filters modify strings.
append
string |
append:
string
Adds a given string to the end of a string.
{{ shop.url | append: product.url }}
{
"product": {
"url": "/products/reverse-short-sleeve-tee"
}
}
https://shop.myshoplaza.com/products/reverse-short-sleeve-tee
camelcase
string |
camelcase
Converts a string to CamelCase.
{{ 'camel-case' | camelcase }}
CamelCase
capitalize
string |
capitalize
Capitalizes every word in a string.
{{ 'this sentence should start with a capitalized word.' | capitalize }}
This Sentence Should Start With A Capitalized Word.
downcase
string |
downcase
Converts a string to all lowercase characters.
{{ product.title | downcase }}
{
"product": {
"title": "Ace Cashmere Beanie"
}
}
ace cashmere beanie
escape
string |
escape
Escapes special characters in HTML, such as <>
, '
, "
, and &
, and converts characters into escape sequences. The filter doesn't affect characters within the string that don’t have a corresponding escape sequence.
{{ '<p>Text to be escaped.</p>' | escape }}
<p>Text to be escaped.</p>
escape_once
string |
escape_once
Escapes a string without changing characters that have already been escaped.
{% assign escaped_text = '<p>Text to be escaped.</p>' | escape %}
{{ escaped_text }}
{{ escaped_text | escape_once }}
<p>Text to be escaped.</p>
<p>Text to be escaped.</p>
handleize
string |
handleize
Converts a string into a handle.
Note
The
handleize
filter has an alias ofhandle
.
{{ product.title | handleize }}
{{ product.title | handle }}
{
"product": {
"title": "Ace Cashmere Beanie"
}
}
ace-cashmere-beanie
ace-cashmere-beanie
hmac_sha1
string |
hmac_sha1:
string
Converts a string into an SHA-1 hash using a hash message authentication code (HMAC).
The secret key for the message is supplied as a parameter to the filter.
{{ 'Ace' | hmac_sha1: 'Salty' }}
5da24ef75f6a8fc7d28c0fcc7236244d29a4511d
hmac_sha256
string |
hmac_sha256:
string
Converts a string into an SHA-256 hash using a hash message authentication code (HMAC).
The secret key for the message is supplied as a parameter to the filter.
{{ 'Ace' | hmac_sha256: 'Salty' }}
8f688efb30c4e26bed3e14923030f9276e463e7933c88fc18c0ff0c934185418
lstrip
string |
lstrip
Strips all whitespace from the left of a string.
{% assign text = ' Some fruits create whitespace. ' %}
"{{ text }}"
"{{ text | lstrip }}"
" Some fruits create whitespace. "
"Some fruits create whitespace. "
md5
string |
md5
Converts a string into an MD5 hash.
{{ '' | md5 }}
d41d8cd98f00b204e9800998ecf8427e
newline_to_br
string |
newline_to_br
Converts newlines (\n
) in a string to HTML line breaks (<br>
).
{% capture description %}
<h3>Sound inspired</h3>
<div>Get inspired with Solo Pro wireless headphones.</div>
{% endcapture %}
{{ description | newline_to_br }}
<br>
<h3>Sound inspired</h3>
<br>
<div>Get inspired with Solo Pro wireless headphones.</div>
<br>
pluralize
number |
pluralize:
string,
string
Outputs the singular or plural version of a string based on a given number.
{% assign item_count = cart.cart %}
Cart item count: {{ item_count }} {{ item_count | pluralize: 'item', 'items' }}
{
"cart": {
"item_count": 2
}
}
Cart item count: 2 items
prepend
string |
prepend:
string
Adds a given string to the beginning of a string.
{{ product.url | prepend: shop.url }}
{
"product": {
"url": "/products/reverse-short-sleeve-tee"
}
}
https://shop.myshoplaza.com/products/reverse-short-sleeve-tee
remove
string |
remove:
string
Removes any instance of a substring inside a string.
{{ "I can't do it!" | remove: "'t" }}
I can do it!
remove_first
string |
remove_first:
string
Removes the first instance of a substring inside a string.
{{ "I don't know why, but I don't know how to do it." | remove_first: "don't" }}
I know why, but I don't know how to do it.
replace
string |
replace:
string,
string
Replaces any instance of a substring inside a string with a given string.
{{ product.handle | replace: '-', ' ' }}
{
"product": {
"handle": "ace-cashmere-beanie"
}
}
ace cashmere beanie
replace_first
string |
replace_first:
string,
string
Replaces the first instance of a substring inside a string with a given string.
{{ product.handle | replace_first: '-', ' ' }}
{
"product": {
"handle": "ace-cashmere-beanie"
}
}
ace cashmere-beanie
rstrip
string |
rstrip
Strips all whitespace from the right of a string.
{% assign text = ' Some fruits create whitespace. ' %}
"{{ text }}"
"{{ text | rstrip }}"
" Some fruits create whitespace. "
" Some fruits create whitespace."
sha1
string |
sha1
Converts a string into an SHA-1 hash.
{{ 'Ace' | sha1 }}
fc2b5a9cb80ab0a1526f4fbc887646dd245632c2
sha256
string |
sha256
Converts a string into an SHA-256 hash.
{{ 'Ace' | sha256 }}
a467da82da540f56097b7224d81612bfa212e26efbf0709606144fee0b82a631
slice
string |
slice
Returns a substring or series of array items, starting at a given 0-based index.
By default, the substring has a length of one character, and the array series has one array item. However, you can provide a second parameter to specify the number of characters or array items.
{{ collection.title | slice: 0 }}
{{ collection.title | slice: 0, 3 }}
{{ collection.tags | slice: 1, 2 | join: ', ' }}
{
"collection": {
"tags": [
"Burning",
"fresh",
"music",
"plant",
"Salty"
],
"title": "All products"
}
}
All products
All
fresh, music
Negative index
You can supply a negative index which will count from the end of the string.
{{ title | slice: -8, 8 }}
{
"collection": {
"title": "All products"
}
}
products
split
string |
split:
string
Splits a string into an array of substrings based on a given separator.
{% assign title_words = product.handle | split: '-' %}
{% for word in title_words %}
{{ word }}
{% endfor %}
{
"product": {
"handle": "ace-cashmere-beanie"
}
}
ace
cashmere
beanie
strip
string |
strip
Strips all whitespace from the left and right of a string.
{% assign text = ' Some fruits create whitespace. ' %}
"{{ text }}"
"{{ text | strip }}"
" Some fruits create whitespace. "
"Some fruits create whitespace."
strip_html
string |
strip_html
Strips all HTML tags from a string.
<!-- With HTML -->
{{ product.description }}
<!-- HTML stripped -->
{{ product.description | strip_html }}
{
"product": {
"description": "<h3>Sound inspired</h3>\n<div>Get inspired with Solo Pro wireless headphones. To deliver sound how you want it, Solo Pro features two listening modes: Active Noise Cancelling (ANC) and Transparency mode.</div>"
}
}
<!-- With HTML -->
<h3>Sound inspired</h3>
<div>Get inspired with Solo Pro wireless headphones. To deliver sound how you want it, Solo Pro features two listening modes: Active Noise Cancelling (ANC) and Transparency mode.</div>
<!-- HTML stripped -->
Sound inspired
Get inspired with Solo Pro wireless headphones. To deliver sound how you want it, Solo Pro features two listening modes: Active Noise Cancelling (ANC) and Transparency mode.
strip_newlines
string |
strip_newlines
Strips all newline characters (line breaks) from a string.
<!-- With newlines -->
{{ product.description }}
<!-- Newlines stripped -->
{{ product.description | strip_newlines }}
{
"product": {
"description": "<h3>Sound inspired</h3>\n<div>Get inspired with Solo Pro wireless headphones. To deliver sound how you want it, Solo Pro features two listening modes: Active Noise Cancelling (ANC) and Transparency mode.</div>"
}
}
<!-- With newlines -->
<h3>Sound inspired</h3>
<div>Get inspired with Solo Pro wireless headphones. To deliver sound how you want it, Solo Pro features two listening modes: Active Noise Cancelling (ANC) and Transparency mode.</div>
<!-- Newlines stripped -->
<h3>Sound inspired</h3><div>Get inspired with Solo Pro wireless headphones. To deliver sound how you want it, Solo Pro features two listening modes: Active Noise Cancelling (ANC) and Transparency mode.</div>
truncate
string |
truncate:
number
Truncates a string down to a given number of characters.
If the specified number of characters is less than the length of the string, then an ellipsis (...
) is appended to the truncated string. The ellipsis is included in the character count of the truncated string.
{{ product.title | truncate: 10 }}
{{ product.title | truncate: 20 }}
{
"product": {
"title": "Ace Cashmere Beanie"
}
}
Ace Cas...
Ace Cashmere Beanie
Specify a custom ellipsis
string |
truncate:
number,
string
You can provide a second parameter to specify a custom ellipsis. If you don't want an ellipsis, then you can supply an empty string.
{{ product.title | truncate: 10, '' }}
{{ product.title | truncate: 10, '···' }}
{
"product": {
"title": "Ace Cashmere Beanie"
}
}
Ace Cashme
Ace ···
truncatebytes
string |
truncatebytes:
number
Truncates a string down to a given number of bytes.
If the specified number of characters is less than the length of the string, then an ellipsis (...
) is appended to the truncated string. The ellipsis is included in the character count of the truncated string.
{{ product.description | truncatebytes: 50 }}
{
"product": {
"description": "Get inspired with Solo Pro wireless headphones. To deliver sound how you want it, Solo Pro features two listening modes: Active Noise Cancelling (ANC) and Transparency mode. Beats’ Pure ANC gives you the space to create with fully immersive sound, while Transparency mode helps you stay aware of your surroundings. Every detail of Solo Pro has been carefully considered, right down to the intuitive way the headphones turn on and off via folding. The ergonomic design delivers exceptional comfort for extended wear and sleek style. And with up to 22 hours of battery life, you can keep the music going no matter where your day takes you."
}
}
Get inspired with Solo Pro wireless headphones....
Specify a custom ellipsis
string |
truncatebytes:
number,
string
You can provide a second parameter to specify a custom ellipsis. If you don't want an ellipsis, then you can supply an empty string.
{{ product.description | truncatebytes: 50, '' }}
{{ product.description | truncatebytes: 50, '···' }}
{
"product": {
"description": "Get inspired with Solo Pro wireless headphones. To deliver sound how you want it, Solo Pro features two listening modes: Active Noise Cancelling (ANC) and Transparency mode. Beats’ Pure ANC gives you the space to create with fully immersive sound, while Transparency mode helps you stay aware of your surroundings. Every detail of Solo Pro has been carefully considered, right down to the intuitive way the headphones turn on and off via folding. The ergonomic design delivers exceptional comfort for extended wear and sleek style. And with up to 22 hours of battery life, you can keep the music going no matter where your day takes you."
}
}
Get inspired with Solo Pro wireless headphones. To
Get inspired with Solo Pro wireless headphon···
truncatewords
string |
truncatewords:
number
Truncates a string down to a given number of words.
If the specified number of words is less than the number of words in the string, then an ellipsis (...
) is appended to the truncated string.
{{ product.description | truncatewords: 10 }}
{
"product": {
"description": "Get inspired with Solo Pro wireless headphones. To deliver sound how you want it, Solo Pro features two listening modes: Active Noise Cancelling (ANC) and Transparency mode. Beats’ Pure ANC gives you the space to create with fully immersive sound, while Transparency mode helps you stay aware of your surroundings. Every detail of Solo Pro has been carefully considered, right down to the intuitive way the headphones turn on and off via folding. The ergonomic design delivers exceptional comfort for extended wear and sleek style. And with up to 22 hours of battery life, you can keep the music going no matter where your day takes you."
}
}
Get inspired with Solo Pro wireless headphones. To deliver sound...
Specify a custom ellipsis
string |
truncatewords:
number,
string
You can provide a second parameter to specify a custom ellipsis. If you don't want an ellipsis, then you can supply an empty string.
{{ product.description | truncatewords: 10, '' }}
{{ product.description | truncatewords: 10, '---' }}
{
"product": {
"description": "Get inspired with Solo Pro wireless headphones. To deliver sound how you want it, Solo Pro features two listening modes: Active Noise Cancelling (ANC) and Transparency mode. Beats’ Pure ANC gives you the space to create with fully immersive sound, while Transparency mode helps you stay aware of your surroundings. Every detail of Solo Pro has been carefully considered, right down to the intuitive way the headphones turn on and off via folding. The ergonomic design delivers exceptional comfort for extended wear and sleek style. And with up to 22 hours of battery life, you can keep the music going no matter where your day takes you."
}
}
Get inspired with Solo Pro wireless headphones. To deliver sound
Get inspired with Solo Pro wireless headphones. To deliver sound---
upcase
string |
upcase
Converts a string to all uppercase characters.
{{ product.title | upcase }}
{
"product": {
"title": "Ace Cashmere Beanie"
}
}
ACE CASHMERE BEANIE
url_decode
string |
url_decode
Decodes any percent-encoded characters in a string.
{{ 'https%3A%2F%2Fwww.shoplazza.com%2F' | url_decode }}
https://www.shoplazza.com/
url_encode
string |
url_encode
Converts any URL-unsafe characters in a string to the percent-encoded equivalent.
Note
Spaces are converted to a
+
character, instead of a percent-encoded character.
{{ 'https://www.shoplazza.com/' | url_encode }}
https%3A%2F%2Fwww.shoplazza.com%2F
Updated over 1 year ago