Skip to main content

CaptureOnContentForBlock

Identifies the usage of content_for "block" inside the capture tag, as it's restricted to enforce static block rendering at its expected location.


The following examples contain code snippets that either fail or pass this check.

In the following example, the content_for "block" tag is used inside of the capture tag:

{% capture x %}
{% content_for "block", type: "text", id:"static-block-id" %}
{% endcapture %}

In the following example, the content_for "block" tag is outside the capture tag, rendering content as expected:

{% capture x %}
Captured content
{% endcapture %}
{% content_for "block", type: "text", id:"static-block-id" %}

The following example contains the default configuration for this check:

CaptureOnContentForBlock:
enabled: true
severity: error
ParameterDescription
enabledWhether this check is enabled.
severityThe severity of the check.

Anchor to Disabling this checkDisabling this check

Disabling this check isn't recommended.


Was this page helpful?