GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Template::Plugin::DataPrinter(3) User Contributed Perl Documentation Template::Plugin::DataPrinter(3)

Template::Plugin::DataPrinter - Template Toolkit dumper plugin using Data::Printer

version 0.015

    [% USE DataPrinter %]

    [% DataPrinter.dump(variable) %]
    [% DataPrinter.dump_html(variable) %]

This is a dumper plugin for Template::Toolkit which uses Data::Printer instead of Data::Dumper.

Data::Printer is a colorised pretty-printer with nicely human-readable object output.

The provided methods match those of Template::Plugin::Dumper.

Generates an ansi-colorised dump of the data structures passed.

    [% USE DataPrinter %]
    [% DataPrinter.dump(myvar) %]
    [% DataPrinter.dump(myvar, yourvar) %]

Generates a html-formatted dump of the data structures passed. The ansi colorisation is converted to html by HTML::FromANSI::Tiny.

    [% USE DataPrinter %]
    [% DataPrinter.dump_html(myvar) %]
    [% DataPrinter.dump_html(myvar, yourvar) %]

This plugin has no configuration of its own, but the underlying Data::Printer and HTML::FromANSI::Tiny modules can be configured using the "dp" and "hfat" parameters.

    [% USE DataPrinter(dp = { ... }, hfat = { ... }) %]
dp
A hashref containing the params to be passed to "Data::Printer::import".

See the Data::Printer documentation for more information.

hfat
A hashref containing the params to be passed to "HTML::FromANSI::Tiny->new".

See the HTML::FromANSI::Tiny documentation for more information.

Colorisation is turned on by default. To turn it off, use Data::Printer's "colored" parameter:

    [% USE DataPrinter(dp = { colored = 0 }) %]

This module can be used more-or-less as a drop-in replacement for the default Dumper plugin by specifying an explicit plugin mapping to the "Template" constructor:

    my $template = Template->new(...,
            PLUGINS => {
                Dumper => 'Template::Plugin::DataPrinter',
            },
        );

Then existing templates such as the one below will automatically use the "DataPrinter" plugin instead.

    [% USE Dumper(Indent=0, Pad="<br>") %]

    [% Dumper.dump(variable) %]
    [% Dumper.dump_html(variable) %]

Any unrecognised constructor parameters are silently ignored, so the "Indent" and "Pad" parameters above will have no effect.

A custom Data::Printer configuration file can be specified like so:

    [% USE DataPrinter(dp = { rc_file = '/path/to/my/rcfile.conf' }) %]

Beware that setting "colored = 0" in your .dataprinter file will not work. This must be specified in the "USE DataPrinter" code.

    [% USE DataPrinter(dp = { rc_file = '...', colored = 0 }) %]

Setting "colored = 0" in the .dataprinter file will not work. The "colored = 0" setting must appear in the "USE DataPrinter" line.

  • Template::Toolkit
  • Data::Printer
  • HTML::FromANSI::Tiny

Stephen Thirlwall <sdt@cpan.org>

This software is copyright (c) 2021 by Stephen Thirlwall.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2021-04-29 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.