Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

tokuhirom (7396)

tokuhirom
  (email not shown publicly)
http://d.hatena.ne.jp/tokuhirom/

Journal of tokuhirom (7396)

Friday November 03, 2006
09:41 AM

Sledge::View 0.04 released

[ #31498 ]

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.