Filters
From Shopify Wiki
(Redirected from FilterReference)
Filters manipulate the output of variables. Filters look like this {{ variablename | filtername }}. For example:
{{ product.title | upcase }}
YOUR PRODUCT TITLE
Contents |
HTML Filters
- img_tag Wraps element in <img> tag. img_tag(url, alt="")
- script_tag Wraps element in <script> tag
- stylesheet_tag Wraps link in a stylesheet <link> tag
URL Filters
- asset_url Returns the url for an asset.
- global_asset_url Returns the url for a global asset.
- link_to Creates a <a href=""> tag. link_to: 'http://example.com', 'title tag text'
- link_to_vendor Creates a link to the vendor page
- link_to_type Creates a link to the type page
- link_to_tag Creates a link to the tag page
- link_to_theme Generates a link to switch to a different theme by role
- link_to_add_tag Links to products that have the given tag and any previously applied tags
- link_to_remove_tag
- product_img_url Generates a product image's URL for a particular size img_url: 'size'
- collection_img_url Generates a collection image's URL for a particular size img_url: 'size'
- theme_url Generates a URL to switch to a different theme by role
- url_for_vendor Creates an url for a vendor name
- url_for_type Creates an url for type name
- url_for_product Creates an url to a product page based on a handleized product title
Money Filters
- money_with_currency Takes a number and wraps in the currency symbol and descriptor
- money_without_currency Formats the number, but displays no currency symbol or descriptor
- money Converts a number into a string based on your currency
Math Filters
- plus Adding input to operand plus: 10
- minus Subtracting input from operand minus: 10
- times Multiplying input by operand times: 10
- divided_by Dividing input by operand divided_by: 10
Manipulation Filters
- append Append characters to a string
- camelize Converts into CamelCase, strips spaces and irregular characters
- capitalize Capitalizes a string
- date Reformat a date
- default_pagination Use with the paginate liquid tag to create pagination
- downcase Converts a string into lowercase
- escape Escapes a string
- first Get the first element of the passed in array
- handleize Non-word characters are stripped out and characters are lowercased
- highlight_active_tag Creats a span with the class "active"
- join Joins an array with a specified character join: ', '
- last Get the last element in an array
- replace_first Replace the first occurrence of a string with another
- remove Removes all occurrences of the substring from the input remove: 'red'
- remove_first Removes only the first occurrence of the substring from the input remove_first: 'red'
- newline_to_br Inserts a <br /> tag in front of every \n linebreak character.
- pluralize Can make a word plural pluralize: 'item', 'items'
- prepend Append characters to a string
- size Return the size of an array or string
- split Divides a string into substrings based on a delimiter, returning an array of these substrings
- strip_html Striple all html tags from string
- strip_newlines Removes all newlines from the input
- replace Will replace all occurrences of a string with another
- truncate Truncate a string down to x characters
- truncatewords Truncate string down to x words
- upcase Convert a input string to uppercase
- weight_with_unit Converts a weight into the unit system of the shop
- json Converts some content into a JSON string
