Created
August 31, 2011 10:12
-
-
Save kraih/1183234 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
use Mojo::DOM; | |
# Parse HTML5 snippet | |
my $dom = Mojo::DOM->new(<<EOF); | |
<div> | |
<a href="http://search.cpan.org"> | |
<img src="/images/search.png"> | |
</a> | |
<a href="http://mojolicio.us"> | |
<p>Mojolicious</p> | |
</a> | |
<a href="http://metacpan.org"> | |
<p><img src="/images/metacpan.png"></p> | |
</a> | |
</div> | |
EOF | |
# Add class attribute to all image links | |
$dom->find('$a img')->each(sub { shift->{class} = 'logo' }); | |
# Render HTML5 snippet | |
print "$dom"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Whats the reason you are using the dollar-sign instead of the exclamation mark like in the w3c proposal? Wouldn't it be saner to stay standard-compliant?