[1.0.0-beta2] Make twig function more tolerant

Created on 16 October 2024, about 1 month ago

Problem/Motivation

icon() Twig function expects valid values for icon_pack & icon:

  public function getIconRenderable(string $icon_pack_id, string $icon_id, ?array $settings = []): array {

So, we need to always wrap the function around a test:

{% if icon %}
{{ icon(icon.icon_pack, icon.icon, icon.settings) %}  
{% endif %} 

Proposed resolution

Move the test to the Twig function itself so we don't need to add it in the template.

Non tested proposal:

  public function getIconRenderable(?string $icon_pack_id, ?string $icon_id, ?array $settings = []): array {
    if (!$icon_pack_id || !$icon_id) {
      return [];
    }
📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France pdureau Paris

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