![]() |
![]()
| ![]() |
![]()
NAMETemplate::Plugin::DataPrinter - Template Toolkit dumper plugin using Data::PrinterVERSIONversion 0.015SYNOPSIS[% USE DataPrinter %] [% DataPrinter.dump(variable) %] [% DataPrinter.dump_html(variable) %] DESCRIPTIONThis 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. METHODSThe provided methods match those of Template::Plugin::Dumper.dumpGenerates an ansi-colorised dump of the data structures passed.[% USE DataPrinter %] [% DataPrinter.dump(myvar) %] [% DataPrinter.dump(myvar, yourvar) %] dump_htmlGenerates 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) %] CONFIGURATIONThis 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 = { ... }) %]
Disabling colorisationColorisation is turned on by default. To turn it off, use Data::Printer's "colored" parameter:[% USE DataPrinter(dp = { colored = 0 }) %] Using as a drop-in replacement for Template::Plugin::DumperThis 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. Using a custom .dataprinter fileA 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 }) %] BUGSSetting "colored = 0" in the .dataprinter file will not work. The "colored = 0" setting must appear in the "USE DataPrinter" line.SEE ALSO
AUTHORStephen Thirlwall <sdt@cpan.org>COPYRIGHT AND LICENSEThis 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.
|