1 #==============================================================================
3 # Template::Plugin::Dumper
7 # A Template Plugin to provide a Template Interface to Data::Dumper
10 # Simon Matthews <sam@tt2.org>
13 # Copyright (C) 2000 Simon Matthews. All Rights Reserved
15 # This module is free software; you can redistribute it and/or
16 # modify it under the same terms as Perl itself.
18 #==============================================================================
20 package Template::Plugin::Dumper;
24 use base 'Template::Plugin';
28 our $DEBUG = 0 unless defined $DEBUG;
29 our @DUMPER_ARGS = qw( Indent Pad Varname Purity Useqq Terse Freezer
30 Toaster Deepcopy Quotekeys Bless Maxdepth );
33 #==============================================================================
34 # ----- CLASS METHODS -----
35 #==============================================================================
37 #------------------------------------------------------------------------
38 # new($context, \@params)
39 #------------------------------------------------------------------------
42 my ($class, $context, $params) = @_;
47 foreach my $arg (@DUMPER_ARGS) {
49 if (defined ($val = $params->{ lc $arg })
50 or defined ($val = $params->{ $arg })) {
51 ${"Data\::Dumper\::$arg"} = $val;
62 my $content = Dumper @_;
69 my $content = Dumper @_;
85 Template::Plugin::Dumper - Plugin interface to Data::Dumper
91 [% Dumper.dump(variable) %]
92 [% Dumper.dump_html(variable) %]
96 This is a very simple Template Toolkit Plugin Interface to the L<Data::Dumper>
97 module. A C<Dumper> object will be instantiated via the following directive:
101 As a standard plugin, you can also specify its name in lower case:
105 The C<Data::Dumper> C<Pad>, C<Indent> and C<Varname> options are supported
106 as constructor arguments to affect the output generated. See L<Data::Dumper>
109 [% USE dumper(Indent=0, Pad="<br>") %]
111 These options can also be specified in lower case.
113 [% USE dumper(indent=0, pad="<br>") %]
117 There are two methods supported by the C<Dumper> object. Each will
118 output into the template the contents of the variables passed to the
123 Generates a raw text dump of the data structure(s) passed
126 [% Dumper.dump(myvar) %]
127 [% Dumper.dump(myvar, yourvar) %]
131 Generates a dump of the data structures, as per L<dump()>, but with the
132 characters E<lt>, E<gt> and E<amp> converted to their equivalent HTML
133 entities and newlines converted to E<lt>brE<gt>.
136 [% Dumper.dump_html(myvar) %]
140 Simon Matthews E<lt>sam@tt2.orgE<gt>
144 Copyright (C) 2000 Simon Matthews. All Rights Reserved.
146 This module is free software; you can redistribute it and/or
147 modify it under the same terms as Perl itself.
151 L<Template::Plugin>, L<Data::Dumper>