I released Sledge::View 0.04 released.
This distribution includes the Sledge::View::CSV.
yeah, Japanese sales person often requires the CSV formatted files
usage:
package Your::Pages::Admin::Report;
use strict;
use warnings;
use base qw/Sledge::Pages::Compat/;
use Sledge::Plugin::View;
use Sledge::Plugin::Stash;
__PACKAGE__->add_trigger(
AFTER_DISPATCH => sub {
my $self = shift;
if ($self->r->param('output') eq 'csv') {
$self->view('CSV')->process;
}
else {
$self->view('Template')->process;
}
}
);
sub dispatch_report {
my $self = shift;
$self->stash->{row} = [[qw/a b/], [qw/c d/]];
}
and, your template is:
<table>
[% FOR row IN rows %]
<tr>
[% FOR col IN row %]
<td>[% col %]</td>
[% END %]
</tr>
[% END %]
</table>
if user access to '/admin/report/report' then get the html table report, and if access to '/admin/report/report?output=csv' then get the csv report.
yes, you can easy to change the view.
Sledge::View 0.04 released 0 Comments More | Login | Reply /