- map
- Accepts an array element's
attribute as a parameter and creates a string out of each array element's
value.
{% assign collection_titles = collections | map: 'title' %} {{ collection_titles }}
SpringSummerFallWinter
- size
- Returns the size of a string
or an array.
{{ 'is this a 30 character string?' | size }}
30
size can be used in dot notation, in cases where
it needs to be used inside a tag.
{% if collections.frontpage.products.size > 10 %} There are more than 10 products in this collection! {% endif %}
- script_tag
- Generates a script tag.
{{ 'shop.js' | asset_url | script_tag }}
<script src="//cdn.Haravan.com/s/files/1/0087/0462/t/394/assets/shop.js?28178" type="text/javascript"> </script>
- ceil
- Rounds an output up to the
nearest integer.
{{ 4.6 | ceil }}
{{ 4.3 | ceil }}
5
5
- divided_by
- Divides an output by a
number.
<!-- product.price = 200 -->
{{ product.price | divided_by: 10 }}
20
- floor
- Rounds an output down to the
nearest integer.
{{ 4.6 | floor }}
{{ 4.3 | floor }}
4
4
- round
- Rounds the output to the
nearest integer or specified number of decimals.
{{ 4.6 | round }}
5
- times
- Multiplies an output by a
number.
<!-- product.price = 200 -->
{{ product.price | times: 1.15 }}
230
- modulo
- Divides an output by a number
and returns the remainder.
{{ 12 | modulo:5 }}
2
- camelcase
- Converts a string into
CamelCase.
{{ 'coming-soon' | camelcase }}
ComingSoon
- md5
- Converts a string into an MD5
hash. An example use case for this filter is showing the Gravatar image associated
with the poster of a blog comment:
<img src="http://www.gravatar.com/avatar/{{ comment.email | remove: ' ' | strip_newlines | downcase | md5 }}" />
<img src="http://www.gravatar.com/avatar/2a95ab7c950db9693c2ceb767784c201" />
- slice
- The slice filter returns a
substring, starting at the specified index. An optional second parameter can be
passed to specify the length of the substring. If no second parameter is given, a
substring of one character will be returned.
{{ "hello" | slice: 0 }}
{{ "hello" | slice: 1 }}
{{ "hello" | slice: 1, 3 }}
h
e
ell
If the passed index is
negative, it is counted from the end of the string.
{{ "hello" | slice: -3, 2 }}
{{ "hello" | slice: -3, 2 }}
- split
- The split filter takes on a
substring as a parameter. The substring is used as a delimiter to divide a string
into an array.
{% assign words = "Uses cheat codes, calls the game boring." | split: ' ' %}
First word: {{ words.first }}
First word: {{ words[0] }}
Second word: {{ words[1] }}
Last word: {{ words.last }}
All words: {{ words | join: ', ' }}
{% for word in words %}
{{ word }}
{% endfor %}
First word: Uses
First word: Uses
Second word: cheat
Last word: boring.
All words: Uses, cheat, codes,, calls, the, game, boring.
Uses cheat codes, calls the game boring.
- lstrip
- Strips tabs, spaces, and
newlines (all whitespace) from the left side of a string..
"{{ ' too many spaces ' | lstrip }}"
<!-- Notice the empty spaces to the right of the string -->
too many spaces
- rstrip
- Strips tabs, spaces, and
newlines (all whitespace) from the right side of a string.
{{ ' too many spaces ' | strip }}
too many spaces
- uniq
- Removes any duplicate
instances of an element in an array.
{% assign fruits = "orange apple banana apple orange" %} {{ fruits | split: ' ' | uniq | join: ' ' }}
orange apple banana
- url_escape
- Identifies all characters in
a string that are not allowed in URLS, and replaces the characters with their
escaped variants.
{{ " & " | url_escape }}
%3Chello%3E%20&%20%3CHaravan%3E
- url_param_escape
- Replaces all characters in a
string that are not allowed in URLs with their escaped variants, including the
ampersand (&).
{{ " & " | url_param_escape }}
%3Chello%3E%20%26%20%3CHaravan%3E
- file_url
- Returns the URL of a file in
the Files page of the admin.
{{ 'size-chart.pdf' | file_url }}
//cdn.Haravan.com/s/files/1/0087/0462/files/size-chart.pdf?28261
- customer_login_link
- Generates a link to the
customer log in page.
{{ 'Log in' | customer_login_link }}
<a href="/account/login" id="customer_login_link">Log in
- payment_type_img_url
- Returns the URL of the
payment type's SVG image. Used in conjunction with the shop.enabled_payment_types
variable.
{% for type in shop.enabled_payment_types %} <img src="{{ type | payment_type_img_url }}" /> {% endfor %}
<!-- If shop accepts American Express, MasterCard and Visa --> <img src="//cdn.Haravan.com/s/global/payment_types/creditcards_american_express.svg?3cdcd185ab8e442b12edc11c2cd13655f56b0bb1">
- Haravan_asset_url
- Returns the URL of a global
assets that are found on Haravan's servers. Globally-hosted assets
include:
option_selection.js
api.jquery.js
Haravan_common.js,
customer_area.js
currencies.js
customer.css
{{ 'option_selection.js' | Haravan_asset_url | script_tag }}
<script src="//cdn.Haravan.com/s/Haravan/option_selection.js?20cf2ffc74856c1f49a46f6e0abc4acf6ae5bb34" type="text/javascript"></script>
- default_errors
- Outputs default error
messages for the form.errors variable. The messages returned are dependent on the
strings returned by form.errors.
{% if form.errors %} {{ form.errors | default_errors }} {% endif %}
<!-- if form.errors returned "email" --> Please enter a valid email address.
- json
- Converts a string into JSON
format.
var content = {{ pages.page-handle.content | json }};
The json filter can also used to make Liquid objects readable by
JavaScript:
var json_product = {{ collections.featured.products.first | json }};
var json_cart = {{ cart | json }};
- escape(input)
- Use this filter to escape a
string.
{{ link.title | escape }}
- append(input)
- Use this filter to append
characters to a string.
{{ 'sales' | append: '.jpg' }}
sales.jpg
- prepend(input)
- Use this filter to prepend
characters to a string.
- size(input)
- Return the size of an array
or string
{{ 'this is an 30 character string' | size }}
30
- join(input, segmenter = ' ')
- "joins" an array with the
specified character. Example:
{{ product.tags | join: ', ' }}
tag1, tag2, tag3
- downcase(input)
- convert a input string to
'downcase'
- upcase(input)
- convert a input string to
UPCASE
- strip_html
- This will strip all html tags
from the text passed to the block. Useful in combination with truncate.
{{ article.content | strip_html | truncate: 20 }}
- strip_newlines
- Removes all newlines from the
input
- truncate(input, characters = 100)
- Truncate a string down to x
characters. Take care with truncating text which has html elements in it. In these
cases you probably want to run the string through the strip_html filter first (see
below).
- truncatewords(input, words = 15)
- Truncate string down to x
words
- date(input, format)
- Reformat a date
- %a - The abbreviated weekday name (``Sun'')
- %A - The full weekday name (``Sunday'')
- %b - The abbreviated month name (``Jan'')
- %B - The full month name (``January'')
- %c - The preferred local date and time representation
- %d - Day of the month (01..31)
- %H - Hour of the day,24-hour clock (00..23)
- %I - Hour of the day,12-hour clock (01..12)
- %j - Day of the year (001..366)
- %m - Month of the year (01..12)
- %M - Minute of the hour (00..59)
- %p - Meridian indicator (``AM'' or ``PM'')
- %S - Second of the minute (00..60)
- %U - Week number of the current year, starting with the first Sunday as the
first day of the first week (00..53)
- %W - Week number of the current year, starting with the first Monday as the
first day of the first week (00..53)
- %w - Day of the week (Sunday is 0,0..6)
- %x - Preferred representation for the date alone,no time
- %X - Preferred representation for the time alone,no date
- %y - Year without a century (00..99)
- %Y - Year with century
- %Z - Time zone name
- %% - Literal ``%'' character
- first(array)
- Get the first element of the
passed in array
{{ product.images | first | to_img }}
- last(array)
- Get the last element of the
passed in array
{{ product.images | last | to_img }}
- newline_to_br
- Inserts a <br />
linebreak tag in front of every \n linebreak character.
- replace(input, substring, replacement)
- Will replace all occurrences
of a string with another.
{{ product.description | replace: 'super', 'mega' }}
- replace_first(input, substring, replacement)
- Will replace the first
occurrence of a string with another.
{{ product.description | replace_first: 'super', 'mega' }}
- remove(input, substring)
- Removes all occurrences of
the substring from the input.
{{ product.description | remove: 'way too expensive'}}
- remove_first(input, substring)
- Removes only the first
occurrence of the substring from the input.
{{ product.description | remove_first: 'remove-me'}}
- plus(input, operand)
- Gets the result of adding
input to operand. When strings are passed, it parses strings as integers before
adding.
Showing {{ paginate.current_offset }}-{{ paginate.current_offset | plus: paginate.page_size }} items
- minus(input, operand)
- Gets the result of
subtracting input from operand. When strings are passed, it parses strings as
integers before adding.
{{ product.price | minus: 10 | money_with_currency }}