Force Filter

Forces Liquid filter | expressions onto newlines when the number of filters contained on a tag exceeds the limit defined. By default, this rule uses a value of 0 which will result in Liquid filters being forced when the tag or output token containing them spans ¾ (or 75%) of defined global wrap limit. This is a Liquid specific formatting rule which defaults to using 0 when no option has been specified.

See fractional wrapping for more information regarding how fraction based thresholds are determined and calculated.

Related Rules

The forceArgument


👍

0

By default, this rule uses a value of 0 which infers forcing to apply at a length ¾ (or 75%) of the defined global wrap limit. If your global wrap is set to 0 then no forcing is applied.


{{ object.prop | filter_1: 'value' | filter_2: 'xxx' }}

{{ object.prop
| filter_1: 'value'
| filter_2: 'xxx' | filter_3: 'foo' }}

{{ object.prop | filter_1: 'value' }}

{{ object.prop | filter_1: 'value' | filter_2: 'xxx' }}

{{ object.prop | filter_1: 'value' | filter_2: 'xxx' | filter_3: 'foo' }}

{{ object.prop | filter_1: 'value' }}

🙌

3

This is an example of the forceFilter using a value of 3 which will result in forcing only if the tag contains 3 or more filters. A tag with less than this number of filters will not have forcing applied (unless wrap is exceeded).


{% # No forcing will be applied as only 2 filters exist %}
{{ object.prop
| filter_1: 'value'
| filter_2: 'xxx' }}

{% # Forcing is applied because there are 3 filters %}
{{ object.prop | filter_1: 'value' | filter_2: 'x' | filter_3: 'foo' }}

{% # No forcing will be applied as only 1 filter exists %}
{{ object.prop
| filter_1: 'value' }}
{% # No forcing will be applied as only 2 filters exist %}
{{ object.prop | filter_1: 'value' | filter_2: 'xxx' }}

{% # Forcing is applied because there are 3 filters %}
{{ object.prop
  | filter_1: 'value'
  | filter_2: 'x'
  | filter_3: 'foo' }}

{% # No forcing will be applied as only 1 filter exists %}
{{ object.prop | filter_1: 'value' }}