Skip to content

Commit

Permalink
added another Mojo::DOM namespace example
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 29, 2012
1 parent 7a19b98 commit 4650721
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,6 +1,6 @@
This file documents the revision history for Perl extension Mojolicious.

2.92 2012-04-28
2.92 2012-04-29
- Improved documentation.
- Improved tests.
- Fixed attribute namespace selector bugs in Mojo::DOM::CSS.
Expand Down
3 changes: 3 additions & 0 deletions lib/Mojo/DOM.pm
Expand Up @@ -533,6 +533,9 @@ Append to element content.
Find a single element with CSS3 selectors. All selectors from
L<Mojo::DOM::CSS> are supported.
# Find first element with "svg" namespace definition
my $namespace = $dom->at('[xmlns\:svg]')->{'xmlns:svg'};
=head2 C<attrs>
my $attrs = $dom->attrs;
Expand Down
13 changes: 5 additions & 8 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -20,33 +20,30 @@ has paths => sub { [] };
# In my day Xmas was about bringing people together,
# not blowing them apart."
sub new {
my $self = shift->SUPER::new(@_);

# Data
$self->add_handler(
# Add "data" handler
my $self = shift->SUPER::new(@_)->add_handler(
data => sub {
my ($r, $c, $output, $options) = @_;
$$output = $options->{data};
}
);

# JSON
# Add "json" handler
$self->add_handler(
json => sub {
my ($r, $c, $output, $options) = @_;
$$output = Mojo::JSON->new->encode($options->{json});
}
);

# Text
$self->add_handler(
# Add "text" handler
return $self->add_handler(
text => sub {
my ($r, $c, $output, $options) = @_;
$$output = $options->{text};
}
);

return $self;
}

sub add_handler {
Expand Down

0 comments on commit 4650721

Please sign in to comment.