I wonder how the fellowmonks pass their model objects into templates. Do you pass directly the objects or do you expand them into individual properties (pass them as hashrefs)?
If you use the first method (objects) how do you pass the additional information for the object?
Let us say we need to display a list of some kind of payments (DBIx::Class objects). It could be comfortable just:
$c->stash(payments => \@payments);
But there are other information we need to supply with each payment:
So would you pass the list like this:
or would you pass just the payments and compute the additional info (and URLs) in template (It doesn't seem very MVCish to me)?$c->stash->{payments} = [ map { { is_due => $this->is_due( $c, $_ ), cancel_url => $c->uri_for_action( '/payment/cancel', [ $_- +>id ] ), detail_url => $c->uri_for_action( '/payment/view', [ $_- +>id ] ), payment_method => $this->payment_method_descr_for( $c, $_->payment_metho +d_id ), # how about the original object ? payment => $_, # or payment_id => $_->id, payment_quantity => $_->quantity, # .... } } @payments ];
Finally how do you pass dates? As objects or formatted already?
Any comments are really appreciated.
In reply to How to organize Catalyst stash by roman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |