From 34733cf1386b729871d1a597548c191c8b371844 Mon Sep 17 00:00:00 2001 From: Mikko Tapionlinna Date: Thu, 29 Jun 2023 14:04:53 +0300 Subject: [PATCH] UHF-X: Add better checking for empty title and description fields in components --- templates/misc/component.twig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/misc/component.twig b/templates/misc/component.twig index 9859e460b..68471bee9 100644 --- a/templates/misc/component.twig +++ b/templates/misc/component.twig @@ -44,6 +44,10 @@ Example usage: {% set tag = 'div' %} {% endif %} +{# Check if the fields are empty, ignore html comments, non-breaking spaces (  and character) and whitespace. #} +{% set hasTitle = component_title|render|striptags|replace({" ":" "," ":" "})|trim %} +{% set hasDescription = component_description|render|striptags|replace({" ":" "," ":" "})|trim %} + {% if component_koro %} @@ -51,14 +55,13 @@ Example usage: {% endif %}
- - {% if component_title|render %} + {% if hasTitle %} <{{ component_title_level|default('h2') }} class="component__title"> {{ component_title }} {% endif %} - {% if component_description|render %} + {% if hasDescription %}
{{ component_description}}