From 2a7230298eec56c271b549cebdf56d7fa2e4ada0 Mon Sep 17 00:00:00 2001
From: brabli <67018167+brabli@users.noreply.github.com>
Date: Wed, 26 Feb 2025 10:41:07 +0000
Subject: [PATCH] Add label attribute
---
Resources/views/Badge.html.twig | 6 +++++-
src/Twig/Component/Badge.php | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/Resources/views/Badge.html.twig b/Resources/views/Badge.html.twig
index 9513fb2..b55917d 100644
--- a/Resources/views/Badge.html.twig
+++ b/Resources/views/Badge.html.twig
@@ -1,3 +1,7 @@
- {% block content %}{% endblock %}
+ {% if block('content') is not empty %}
+ {% block content %}{% endblock %}
+ {% else %}
+ {{- this.label -}}
+ {% endif %}
diff --git a/src/Twig/Component/Badge.php b/src/Twig/Component/Badge.php
index d152755..0f334c0 100644
--- a/src/Twig/Component/Badge.php
+++ b/src/Twig/Component/Badge.php
@@ -26,7 +26,7 @@ final class Badge
* @param ?string $colour specify the colour of an objectless badge
* @param bool $outline if the badge should be rendered as an outline
*/
- public function mount(?BadgeableInterface $obj = null, ?string $class = null, ?string $colour = null, bool $outline = false): void
+ public function mount(?BadgeableInterface $obj = null, ?string $class = null, ?string $colour = null, ?string $label = null, bool $outline = false): void
{
if (!$obj && !$colour) {
throw new \RuntimeException(sprintf('You must specify either a colour an instance of "%s".', BadgeableInterface::class));