[Catalyst] beginner question: MVC / HTML, recommended practice

Jon catalyst at bytabok.com
Sun Aug 6 01:22:15 CEST 2006


On 8/3/06, Sarah Berry <berry.sarah at gmail.com> wrote:
> I'm getting ready to create a database-driven HTML table, and I'm
> trying to plan what logic goes where. I'm using TTSite to display my
> pages.
>
> I've already had the opportunity to learn how to pull data from a
> database on another Catalyst page. What I'm stuck on is how best to
> generate the HTML table once I've got the data.  The structure of the
> table itself, and not just its contents, will depend heavily on the
> data.
>

I'd go for either making the data in the db more consistent, ie having
different tables for different data rather than (guessing here) having
texts and types, or putting the logic into the template and doing
somthing like:

sub foo : Local {
    my ($self, $c) = @_;
    $c->stash->{bar} = $c->model ('EvilDead')->find
($c->req->params('some_zombie'));
    $c->stash->{'template'} = 'sara_berry.tt';
}

and then in the template:
[% IF bar.type == "zombie_type" %]
  [% INCLUDE zombie_table.tt %)
 [% ELSIF ... %]
   [% INCLUDE ... %]
 [% END %]

Hopes it helpes



More information about the Catalyst mailing list