Skip to main content

SchemaPresetsStaticBlocks

Warns if a preset static block doesn't have a corresponding content_for block tag.


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

In the following example, the static preset block with id: "block_2" is missing a content_for block:

{% content_for "block", type: "text", id: "block_1" %}

{% schema %}
"presets": [
{
"name": "My preset",
"blocks": {
"block_1": {
"type": "text",
"static": true
},
"block_2": {
"type": "slide",
"static": true
}
}
}
]
{% endschema %}

In the following example, the static preset block with id: "block_2" is missing a content_for block:

{% content_for "block", type: "text", id: "block_1" %}

{% schema %}
"presets": [
{
"name": "My preset",
"blocks": [
{
"type": "text",
"static": true,
"id": "block_1"
},
{
"type": "slide",
"static": true,
"id": "block_2"
}
]
}
]
{% endschema %}

In the following example, all static preset blocks have a content_for block:

{% content_for "block", type: "text", id: "block_1" %}
{% content_for "block", type: "slide", id: "block_2" %}

{% schema %}
"presets": [
{
"name": "My preset",
"blocks": {
"block_1": {
"type": "text",
"static": true
},
"block_2": {
"type": "slide",
"static": true
}
}
}
]
{% endschema %}

In the following example, all static preset blocks have a content_for block:

{% content_for "block", type:"text", id:"block_1" %}
{% content_for "block", type:"slide", id:"block_2" %}

{% schema %}
"presets": [
{
"name": "My preset",
"blocks": [ {
"type": "text",
"static": true,
"id": "block_1"
},
"block_2": {
"type": "slide",
"static": true,
"id": "block_2"
}
]
}
]
{% endschema %}

The following example contains the default configuration for this check:

SchemaPresetsStaticBlocks:
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?