diff --git a/HtmlExtension.php b/HtmlExtension.php index e4cf9d3..266cbde 100644 --- a/HtmlExtension.php +++ b/HtmlExtension.php @@ -108,6 +108,6 @@ public static function htmlClasses(...$args): string } } - return implode(' ', array_unique($classes)); + return implode(' ', array_unique(array_filter($classes, static function($v) { return '' !== $v; }))); } } diff --git a/Tests/Fixtures/html_classes.test b/Tests/Fixtures/html_classes.test index 8a5304c..65ecaba 100644 --- a/Tests/Fixtures/html_classes.test +++ b/Tests/Fixtures/html_classes.test @@ -1,12 +1,12 @@ --TEST-- "html_classes" function --TEMPLATE-- -{{ html_classes('a', {'b': true, 'c': false}, 'd') }} +{{ html_classes('a', {'b': true, 'c': false}, 'd', false ? 'e', true ? 'f', '0') }} {% set class_a = 'a' %} {% set class_b = 'b' %} {{ html_classes(class_a, {(class_b): true})}} --DATA-- return [] --EXPECT-- -a b d +a b d f 0 a b