NAME
Data::Format::Pretty::HTML - Pretty-print data structure for HTML output
VERSION
version 0.07
SYNOPSIS
In your program:
use Data::Format::Pretty::HTML qw(format_pretty);
...
print format_pretty($result);
Some example output:
Scalar, format_pretty("foo & bar"):
foo & bar
Scalar multiline, format_pretty("foo\nbar\nbaz"):
foo
bar
baz
List, format_pretty([qw/foo bar baz qux/]):
Hash,
format_pretty({foo=>"data",bar=>"format",baz=>"pretty",qux=>"html"}):
key | value |
bar | format |
baz | pretty |
foo | data |
qux | html |
2-dimensional array, format_pretty([ [1, 2, ""], [28, "bar", 3], ["foo",
3, undef] ]):
column0 | column1 | column2 |
1 | 2 | |
28 | bar | 3 |
foo | 3 | |
An array of hashrefs, such as commonly found if you use DBI's
fetchrow_hashref() and friends, format_pretty([ {a=>1, b=>2}, {b=>2,
c=>3}, {c=>4} ]):
Some more complex data, format_pretty({summary => "Blah...", users =>
[{name=>"budi", domains=>["f.com", "b.com"], quota=>"1000"},
{name=>"arif", domains=>["baz.com"], quota=>"2000"}], verified => 0}):
summary |
Blah... |
users |
domains | name | quota |
f.com, b.com | budi | 1000 |
baz.com | arif | 2000 |
verified |
0 |
Structures which can't be handled yet will simply be output as YAML,
format_pretty({a => {b=>1}}):
a:
b: 1
DESCRIPTION
This module has the same spirit as Data::Format::Pretty::Console (and
currently implemented as its subclass). The idea is to throw it some
data structure and let it figure out how to best display the data in a
pretty HTML format.
Differences with Data::Format::Pretty::Console:
* hot (hash of table) structure is rendered as table of inner tables
This module uses Log::Any for logging.
FUNCTIONS
format_pretty($data, \%opts)
Return formatted data structure as HTML. Options:
* table_column_orders => [[colname, colname], ...]
See Data::Format::Pretty::Console for more details.
* linkify_urls_in_text => BOOL
Whether to convert 'http://foo' in text into 'http://foo'. Default is true.
SEE ALSO
Data::Format::Pretty
AUTHOR
Steven Haryanto
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
|