Skip to content

Commit

Permalink
[html-extra] filter classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond authored and fabpot committed Apr 29, 2024
1 parent 284a510 commit a517c14
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion extra/html-extra/HtmlExtension.php
Expand Up @@ -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; })));
}
}
4 changes: 2 additions & 2 deletions extra/html-extra/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

0 comments on commit a517c14

Please sign in to comment.