=encoding utf8
=head1 NAME
Mojolicious::Plugin::ReplyTable - Easily render rectangular data in many formats using Mojolicious
=head1 SYNOPSIS
use Mojolicious::Lite; plugin 'ReplyTable';
my $format = [format => [qw( txt csv html json xls xlsx )]]; any '/table' => $format => sub { my $c = shift; my $data = [ [qw/a b c d/], [qw/e f g h/], ]; $c->reply->table($data); };
app->start;
=head1 DESCRIPTION
L
Loading the plugin also sets up several MIME types (using L
=head1 HELPERS
=head2 reply->table
$c->reply->table([[...], [...], ... ]]); $c->reply->table($default => $data, html => sub { ... });
Renders an arrayref of arrayrefs (the inner arrayref being a row) in one of several formats listed below. An optional leading argument is used as the default format when one is not otherwise requested. Optional trailing key-value pairs are merged into the arguments to L<Mojolicious::Controller/respond_to>.
Any additional options, particularly those governing formatting details, are via stash keys prefixed by C
The formats currently include:
=head3 csv
Implemented via L
$c->stash('reply_table.csv_options' => { sep_char => "|" });
See L<Text::CSV/new> for available options.
=head3 html
Implemented via the standard L
=head3 json
Implemented via the standard L
=head3 txt
A textual representation of the table. This format is intended for human consumption and the specific formatting should not be relied upon.
If L
=head3 xls
Binary Microsoft Excel format (for older editions of Excel), provided by optional module L
=head3 xlsx
XML Microsoft Excel format (for newer editions of Excel), provided by optional module L
=head1 METHODS
This module inherits all the methods from L
=head2 register
The typical mechanism of loading a L
=head1 FUTURE WORK
Beyond what is mentioned in the specifc formats above, the following work is planned. If any of it tickles your fancy, pull-requests are always welcome.
=over
=item *
Better tests for generated Excel documents.
=item *
Exposing the formatters so that they can be used directly.
=item *
Add additional formats, like OpenOffice/LibreOffice. If needed these can be appended via additional handlers to the helper.
=back
=head1 A NOTE ON FORMAT DETECTION
As of L
As of Mojolicious 9.16 you can inherit these formats from a parent route:
my $with_formats = $app->routes->any([format => \@formats]); $with_formats->get('/data')->to('MyController#my_action');
=head1 SEE ALSO
=over
=item L
=item Lhttps://metacpan.org/pod/Mojolicious::Plugin::WriteExcel
=back
=head1 SOURCE REPOSITORY
Lhttp://github.com/jberger/Mojolicious-Plugin-ReplyTable
=head1 SPECIAL THANKS
Pharmetika Software, Lhttp://pharmetika.com
=head1 AUTHOR
Joel Berger, Elt>joel.a.berger@gmail.comE<gt
=head1 CONTRIBUTORS
=over
Nils Diewald (Akron)
Красимир Беров (kberov)
Ryan Perry
Ilya Chesnokov (ichesnokov)
=back
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2015 by L and L. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.