Renee Baecker

NAME

Mojolicious::Plugin::JavaScript::Console - use the JavaScript console from Mojolicious applications

VERSION

version 0.02

SYNOPSIS

  use Mojolicious::Lite;
  
  plugin 'JavaScript::Console';
  
  get '/' => sub {
      my $self = shift;
      $self->console->group( 'start' );
      $self->console->log( 'logging with JavaScript::Console' );
      $self->console->warn( 'this is for $foo #25' );
      $self->console->group_end;
  
      $self->console->dir_by_id( 'test' );
  
      $self->render( 
          'index', 
      );
  };
  
  app->start;
  
  __DATA__
  @@ index.html.ep
  <div id="test"><h2>JavaScript::Console</h2></div>
  Please open a JavaScript console
  <%= Mojo::ByteStream->new( console()->output ) %>

DESCRIPTION

Mojolicious::Plugin::JavaScript::Console is a simple plugin to print debug output to a javascript console.

METHODS

register

  # in Mojolicious
  sub format_output {
      return JSON::XS->new->encode( shift );
  }
  
  $app->plugin(
    'JavaScript::Console' => {
      charset   => 'utf-8',
      formatter => \&format_output,
    },
  );

  # in Mojolicious::Lite
  plugin 'JavaScript::Console' => {
    charset   => 'utf-8',
    formatter => \&format_output,
  };

HELPERS

console

  my $console = $c->console;
  $c->console->log( 'Logging output' );

returns a JavaScript::Console object.

REPOSITORY

  http://github.com/reneeb/Mojolicious-Plugin-JavaScript-Console

DEPENDENCIES

  • Mojolicious

  • JavaScript::Console

AUTHOR

Renee Baecker <reneeb@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by Renee Baecker.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)