Additional filters

General filters serve many different purposes including formatting, converting, and applying CSS classes.


Converts a timestamp into another date format.

date accepts the same parameters as Ruby's strftime method. You can find a list of the shorthand formats in Ruby's documentation or use a site like


You can pass a format parameter to the date filter to display the date in a format specific to the storefront's language. There are a few different format options available, and it is also possible to define your own.


Sets a default value for any variable with no assigned value. Can be used with strings, arrays, and hashes.

The default value is returned if the variable resolves to nil, false or an empty string "". A string containing whitespace characters will not resolve to the default value.

To allow variables to return false instead of the default value, you can use the allow_false parameter.


Outputs default error messages for the form.errors variable. The messages returned are dependent on the strings returned by form.errors.


Creates a set of links for paginated results. Used in conjunction with the paginate variable.

Default pagination uses the labels Next » and « Previous for links to the next and previous pages. You can override these labels by passing new words to the default_pagination filter:


Use the format_address filter on an address to print the elements of the address in order according to their locale. The filter will only print the parts of the address that have been provided. This filter works on the addresses page for customers who have accounts in your store, or on your store's address:


Wraps words inside search results with an HTML <strong> tag with the class highlight if it matches the submitted search.terms.


Wraps a tag link in a <span> with the class active if that tag is being used to filter a collection.


Converts a string into JSON format.