[Catalyst] Organizing link generators
Eden Cardim
edencardim at gmail.com
Sat Oct 23 16:57:36 GMT 2010
>>>>> "Evan" == Evan Carroll <me at evancarroll.com> writes:
Evan> My view often needs to generate complex links for chained
Evan> actions. Does anyone have a better way of doing this then
Evan> recreating the link generators in the controller?
$c->stash->{generate_link_edit} = sub {
my $vin = shift;
$c->uri_for_action(
'/auth/company/lot/vin/edit'
, [
$c->stash->{chained_company_id}
, $c->stash->{chained_lot_id}
, $vin
]
, ()
);
};
$c->stash->{generate_link_vehicle_add} = sub {
$c->uri_for_action(
'/auth/company/lot/inventory/add'
, [
$c->stash->{chained_company_id}
, $c->stash->{chained_lot_id}
]
, ()
);
};
You should weaken the $c since that code will leak memory without
it. And yes, that's currently the best way to generate urls (that I can
think of anyway), although you can save some typing by using hash slices
instead.
--
Eden Cardim Need help with your Catalyst or DBIx::Class project?
Code Monkey http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://blog.edencardim.com/ http://www.shadowcat.co.uk/servers/
More information about the Catalyst
mailing list