slots_twig: Allow to check if a slot has content

Created on 4 February 2025, 3 months ago

Problem/Motivation

If you place a slot inside a TWIG template it is sometimes useful to know if the slot has content to be able to wrap it correctly.

Example (Actually you might want the div only if there is slot content):

<div>
  {{ slot(slot_id, cardinality) }}
</div>

Proposed resolution

Introduce a Twig function that can be used to determine whether a slot has content.

Example:

<div>
  {% if slot_has_content(slot_id) %}
    {{ slot(slot_id, cardinality) }}
  {% endif %}
</div>
Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany Harlor Berlin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024