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));