- Issue created by @malcomio
- 🇬🇧United Kingdom malcomio
I think this probably comes from the changes in https://git.drupalcode.org/project/twig_svg/-/commit/b3e19eeeb641f770749... for ✨ Mechanism for including SVGs from PHP code Fixed
- 🇬🇧United Kingdom aaron.ferris
Hmm, the above PR was mainly a lift and shift into a service, seems the origin of the loop was added in https://www.drupal.org/project/twig_svg/issues/3023150 →
We may need something to check if attributes is a string|array and handle as needed. Id need to look at it when I get time.
- 🇬🇧United Kingdom aaron.ferris
I think this fix is good
Complete Example in twig:
{{ icon('icon-name', 'Icon title', ['extra-class', 'another-class'], {'name-one': 'value-one', 'name-two': 'value-two'}, ['wrapper-class-1', 'wrapper-class-2']) }}
Result:
<span class="icon__wrapper wrapper-class-1 wrapper-class-2" data-vd-id="element-jgm31"> <svg role="img" title="Icon title" aria-label="Icon title" class="icon icon--icon-name extra-class another-class" focusable="false" name-one="value-one" name-two="value-two" xmlns:xlink="http://www.w3.org/1999/xlink"> <use xlink:href="#icon-name"></use> </svg> </span>
Example without attributes in twig:
{{ icon('icon-name', 'Icon title') }}
Result:
<span class="icon__wrapper" data-vd-id="element-0wrprv"> <svg role="img" title="Icon title" aria-label="Icon title" class="icon icon--icon-name" focusable="false" xmlns:xlink="http://www.w3.org/1999/xlink"> <use xlink:href="#icon-name"></use> </svg> </span>
Example with just icon name in twig:
{{ icon('icon-name') }}
Result:
<span class="icon__wrapper" data-vd-id="element-yxl9s"> <svg aria-hidden="true" class="icon icon--icon-name" focusable="false" xmlns:xlink="http://www.w3.org/1999/xlink"> <use xlink:href="#icon-name"></use> </svg> </span>
(And no warnings).
- Status changed to RTBC
6 months ago 5:37pm 13 September 2024 -
aaron.ferris →
committed 4408958c on 2.0.x authored by
malcomio →
Resolve #3474004 "Warnings foreach argument"
-
aaron.ferris →
committed 4408958c on 2.0.x authored by
malcomio →
-
malcomio →
authored 1d8b015d on 8.x-1.x
Resolve #3474004 "Warnings foreach argument"
-
malcomio →
authored 1d8b015d on 8.x-1.x
- 🇬🇧United Kingdom aaron.ferris
Merged to 2.x and cherry-picked to 8.x
New releases for both branches.
- Status changed to Fixed
6 months ago 5:46pm 13 September 2024 Automatically closed - issue fixed for 2 weeks with no activity.