TheHobbit has asked for the wisdom of the Perl Monks concerning the following question:

Greetings monks,
I'm looking for a module analogous of HTML::FormBuilder, but targeted to build tables to be used in a Catalyst app.

Ideally, I would have to define a table class with something like

package MyApp::Tables::MyTable; use Some::Fantastic::TableBuilder; has_column column_name => ( # various named parameters );

Here, has_column should be some analogous of has_field in HTML::FormBuilder

Then, in my controller I'll do something like

sub show :Local { my $data = fetch_tabular_data_from_model(); my $table = MyApp::Tables::MyTable->new(); $table->set_data($data); $c->stash(table => $table); $c->stash(template => 'mytable.tt2'); }
Here tabular data means something like a Data::Table instance, or a sequence of row object, such as that returned by a DBIC search.

Later, in mytable.tt2 TT template I'll have a line with

[% table.render %]
and all will magically work :)

For all to magically work I need, at the very least, to be able to put wrappers around things (whole table, rows, individual cells...) by defining wrapper methods/classes as in HTML::FormBuilder

Now there are the questions. First, does a module such as this, or something approaching it, exists? If not, would it be interesting to have it?


Leo TheHobbit

Replies are listed 'Best First'.
Re: Building Tables in Catalyst
by Anonymous Monk on Apr 18, 2013 at 04:29 UTC