Skip to content

Commit

Permalink
[html-extra] filter classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Jan 23, 2024
1 parent 284a510 commit 2dbc861
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions extra/html-extra/HtmlExtension.php
Expand Up @@ -75,7 +75,7 @@ public function dataUri(string $data, string $mime = null, array $parameters = [
$repr .= ';'.$key.'='.rawurlencode($value);
}

if (0 === strpos($mime, 'text/')) {
if (str_starts_with($mime, 'text/')) {
$repr .= ','.rawurlencode($data);
} else {
$repr .= ';base64,'.base64_encode($data);
Expand Down Expand Up @@ -108,6 +108,6 @@ public static function htmlClasses(...$args): string
}
}

return implode(' ', array_unique($classes));
return implode(' ', array_unique(array_filter($classes)));
}
}
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') }}
{% 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
a b

0 comments on commit 2dbc861

Please sign in to comment.