Group
Extension

Matches 3

Pinwheel ( B/BB/BBC/Pinwheel-0.2.7.tar.gz, BBC, 2010; MetaCPAN )
Pinwheel/lib/Pinwheel/Controller.pm ( view source; MetaCPAN )
html' },
    'ics'  => { content_type => 'text/calendar', layout => 0 },
    'json' => { content_type => 'application/json', layout => 0 },
    'mp'   => { content_type => 'text/html' },
    'ram'  =>
 handler-coderef is optional.  For
example:

  respond_to('html', 'txt', 'xml' => \&xml_handler, 'json');

Once a format is selected (TODO, document this) the handler is then invoked;
if no handler wa
Pinwheel ( B/BB/BBC/Pinwheel-0.2.7.tar.gz, BBC, 2010; MetaCPAN )
Pinwheel/lib/Pinwheel/View/Data.pm ( view source; MetaCPAN )
~ /^(xml|atom|rss)$/) {
        return $self->to_xml();
    } elsif ($format eq 'json') {
        return $self->to_json();
    } elsif ($format eq 'yaml') {
        return $self->to_yaml();
    } elsi
html();
    } else {
        croak "Unsupported format";
    }
}

sub to_json
{
    my ($self) = @_;

    return '{' . _to_json(@{$self->{raw}}) . '}';
}

sub to_yaml
{
    my ($self) = @_;

    retur

{
    my ($self) = @_;

    return "<?xml version=\"1.0\"?>\n" . _to_xml(@{$self->{raw}});
}

## JSON with HTML syntax highlighting
sub to_html
{
    my ($self) = @_;

    return "<!DOCTYPE html PUBL
Pinwheel ( B/BB/BBC/Pinwheel-0.2.7.tar.gz, BBC, 2010; MetaCPAN )
Pinwheel/lib/Pinwheel/View/Data.pod ( view source; MetaCPAN )
 as JSON:

  {"br":null}
  {"body":{"class":"episode"}}
  {"strong":"important content"}
  {"a":{"href":"/foo","$":"Link to foo"}}

Note the last two lines.  If a tag contains attributes, the JSON val
ue
will be a hash containing those attributes.  If a tag doesn't contain
attributes, the JSON value will be either null or a string.  If a tag
contains both attributes and a string value, the string w
 is converted to a "$" in the JSON/YAML
serialisations, eg:

  TAG("po:microsite", "rdf:resource" => "/foo");

As XML:

  <po:microsite rdf:resource="/foo"/>

And as JSON:

  {"po$microsite":{"rdf$res

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.