Ad

Liquid Shorthands?

- 1 answer

Are there any liquid shorthands? For example I'm trying to express this in a more concise way:

{% if job.offsite %}}
  {{job.offsite}}
{{% else %}}
  {{ job.url }}
{% endif %}
Ad

Answer

For this particular example, you could write:

{{ job.offsite | default: job.url }}

The value provided to the default filter will be used if the left side of the expression is false or nil.

Ad
source: stackoverflow.com
Ad