Created
May 19, 2013 15:33
-
-
Save autarch/5608009 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub _inlinify_css_rules { | |
my $self = shift; | |
my $html = shift; | |
my $dom = Mojo::DOM->new($html); | |
for my $selector ( sort keys %rules ) { | |
my $styler = sub { | |
my $element = shift; | |
my $style = $element->attrs('style') // q{}; | |
for my $name ( keys %{ $rules{$selector} } ) { | |
$style .= "$name:$rules{$selector}{$name};"; | |
} | |
$element->attrs( style => $style ); | |
}; | |
$dom->find($selector)->each($styler); | |
} | |
return "$dom"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment