Template::Plugin::Dump - alternative dumper plugin with Data::Dump


Template-Plugin-Dump documentation Contained in the Template-Plugin-Dump distribution.

Index


Code Index:

NAME

Top

Template::Plugin::Dump - alternative dumper plugin with Data::Dump

SYNOPSIS

Top

    [% USE Dump %]
    [% Dump.dump( variable ) %]
    [% Dump.dump_html( variable ) %]

DESCRIPTION

Top

This plugin is a simple alternative which uses Data::Dump instead of Data::Dumper. APIs are the same, except this plugin has no configuration options as Data::Dump has none of them.

METHODS

Top

dump

Generates a raw text dump of the data structure(s).

dump_html

Generates a dump, but with the characters <, >, & converted to their equivalent HTML entities, and newlines converted to <br>. White spaces and double quotes will be converted to the equivalent HTML entities as well.

AUTHOR

Top

Kenichi Ishigaki, <ishigaki at cpan.org>

COPYRIGHT AND LICENSE

Top


Template-Plugin-Dump documentation Contained in the Template-Plugin-Dump distribution.

package Template::Plugin::Dump;

use strict;
use Data::Dump;
use Template::Plugin;
use base qw( Template::Plugin );
use vars qw( $VERSION );

$VERSION = '0.02';

sub dump {
  my $self = shift;
  my $content = Data::Dump::dump(@_);
  return $content;
}

sub dump_html {
  my $self = shift;
  my $content = Data::Dump::dump(@_);

  $content =~ s/&/&amp;/g;
  $content =~ s/</&lt;/g;
  $content =~ s/>/&gt;/g;
  $content =~ s/ /&nbsp;/g;
  $content =~ s/"/&quot;/g;
  $content =~ s/\n/<br>\n/g;

  return $content;
}

1;

__END__