Skip to content

Commit

Permalink
filter attributes a little more efficiently
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 25, 2016
1 parent 9e483e2 commit a3d3fcc
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/Mojolicious/Plugin/TagHelpers.pm
Expand Up @@ -169,12 +169,8 @@ sub _tag {

# Attributes
my $attrs = $tree->[2] = {@_};
if ($attrs->{data} && ref $attrs->{data} eq 'HASH') {
while (my ($key, $value) = each %{$attrs->{data}}) {
$key =~ y/_/-/;
$attrs->{lc "data-$key"} = $value;
}
delete $attrs->{data};
if (ref $attrs->{data} eq 'HASH' && (my $data = delete $attrs->{data})) {
@$attrs{map { y/_/-/; lc "data-$_" } keys %$data} = @$data{keys %$data};
}

return Mojo::ByteStream->new(Mojo::DOM::HTML::_render($tree));
Expand Down

0 comments on commit a3d3fcc

Please sign in to comment.