Capturing content_for "block", theme-check error

I’m converting a legacy store to theme blocks architecture.

A common approach used by the devs on the Horizon theme throws a ‘severe’ error. I would like to use a similar approach but I don’t know the consequences of ignoring the error.

{% capture card_image %}
  {% content_for 'block',
    type: '_collection-card-image',
    id: 'collection-card-image',
    closest.collection: collection,
    parent_block_id: block.id %}
{% endcapture %}

{% capture children %}
  {% content_for 'blocks', closest.collection: collection %}
{% endcapture %}

{% render 'collection-card',
  card_image: card_image,
  children: children,
  block: block,
  collection: collection,
  section: section
%}

… throws “Do not capture `content_for “block” / theme-check [CaptureOnContentForBlock]”

The documentation left me none the wiser: “Identifies the usage of content_for “block” inside the capture tag, as it’s restricted to enforce static block rendering at its expected location.”

Can someone explain what the error is for, its actual severity and performance implications, and / or whether I can make like the official devs and just ignore it completely?

1 Like

Where is the severe error being displayed? On theme check?

On theme check, latest version of CLI.

Also! Looking through Dawn, their theme check shows CaptureOnContentForBlock with a custom severity rating on 0; presumably the Shopify devs have downgraded it manually at some point.

https://github.com/Shopify/dawn/actions/runs/13709306505/job/38342151569

I remain lost and confused.

Hi again @Sam_Thompson - if this is downgraded on Dawn and failing on Horizon, it sounds like you can also follow the pattern of downgrading. But let me dig into this a bit more on my side.

1 Like