By Percept on
I have an icons.html.twig file, used to include icons where needed using:
{% include('@mytheme/icons.html.twig') ignore missing with { 'icon': 'arrow-right', 'classes': '' } %}The file itself contains the SVG code for each icon ...
{% if icon == 'menu' %}
<svg class="{{ classes }}" width="20" height="20" viewbox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor" d="M0.375 0.913727C0.375 ..."/>
</svg>
{% endif %}
{% if icon == 'home' %}
<svg class="{{ classes }}" width="20" height="20" viewbox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor" d="M18.7188 ..."/>
</svg>
{% endif %}this works BUT my dblog is getting flooded with errors like the one below ...
User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (regel 98 van /var/www/sites/mysite/web/web/core/lib/Drupal/Core/Render/Element.php).
If I replace the SVG code in icons.html.twig with any plain text/HTML, the errors disappear so ... why is Drupal/Twig giving me errors on render arrays when all I'm doing is including SVG like this?