try - Liquid Filter Reference - 1.1.0

Filter Name try
Group Collections
Version 1.1.0

Description

Tries to call the supplied attribute against the supplied object. Use this when you know the property may or may not exist on the object as a way to indicate that it’s expected and ok for it not to exist.

Examples

{% new Map error_1 = '{"message":"Something is wrong"}' %}
{% new Map error_2 = '{"message":"Oh noes!","code":"RED"}' %}

{{ error_1 | try: "code" }}

{% new Map error_1 = '{"message":"Something is wrong"}' %}
{% new Map error_2 = '{"message":"Oh noes!","code":"RED"}' %}

{{ error_2 | try: "code" }}
RED

Back to Filter List

Back to Liquid Reference for 1.1.0

 

 
Back to Documentation