Other Filters

Filter that cannot be assigned to any of the other groups are listed here.

default

This filter checks whether the input is valid/exists, if not the parameter of the default filter is returned.

Example:


{{ '' | default: 'hello' }}  
{{ 'home' | default: 'hello' }}
{{ product.composer | default: 'There is no known composer' }}
		

Output:


hello
home
There is no known composer
		

hash_code & sha1

The hash_code filter will create a SHA1 hash of the given string.

Example:


{{ 'this is a test' | hash_code }}
		

Output:


FA26BE19DE6BFF93F70BC2308434E4A440BBAD02
		

Note: This filter is exclusive to FlickRocket. If you are using a theme orginating from Shopify and want to use this filter, you need to add this.

md5

Similar to the hash_code filter, but this one will produce a MD5 hash.

Example:


{{ 'this is a test' | md5 }}
		

Output:


54B0C58C7CE9F2A8B551351102EE0938
		

default_errors

This filter is used in conjunction with form errors. If something went wrong on sending a specific form (e.g. login form), then the variable form contains information about the problem in the errors field (of type Errors). In order to produce a meaningful and localized error message, this filter can be used for creating an clear text error message.

Example:

{{ form.errors | default_errors }}

Output:


<div class="errors"><ul><li> The email address is unknown.</li></ul></div>
		

weight_with_unit

In order to provide a localized weight for some given products (or other information like shipping cost groups), you could use the weight_with_unit filter to produce a simple formatted weight output. All weights are internally calculated in grams, but converted to lb where necessary.

Example:


{{ 1533 | weight_with_unit }}
		

Output:


3.38 lbs   (when the customer is in USA)
1,53 kg   (when the customer is in Germany)