Liquid Nesting Depth
Identifies Liquid control-flow tags nested deeper than the configured maxDepth. This check counts nested if, unless, for, case, and tablerow tags. elsif and else branches don't add nesting depth.
Reducing nesting depth helps keep theme files easier to scan and makes conditional rendering behavior easier to follow. When a file exceeds the maximum, flatten the logic by combining conditions, returning early with guard clauses, or moving nested logic into snippets that you render from the original file.
Anchor to ExamplesExamples
The following examples contain code snippets that either fail or pass this check.
Anchor to ✗ Fail✗ Fail
In the following example, the innermost if tag is nested 11 levels deep, which is greater than the default maximum of 10:
Anchor to ✓ Pass✓ Pass
In the following example, the nested conditions are flattened into a single guard, so nesting depth stays at one:
Anchor to OptionsOptions
The following example contains the default configuration for this check:
| Parameter | Description |
|---|---|
enabled | Whether this check is enabled. |
severity | The severity of the check. |
maxDepth | The maximum allowed control-flow nesting depth for a Liquid file. |
Anchor to Disabling this checkDisabling this check
Disabling this check isn't recommended. If you can't avoid violating the rule, then you should disable the check using the comment syntax. This ensures that you intentionally disable the check for each instance.