[Catalyst] reusable view components

Matt S Trout dbix-class at trout.me.uk
Thu May 17 22:41:55 GMT 2007


On Thu, May 17, 2007 at 02:39:44PM -0400, John Goulah wrote:
> Theres probably not one specific answer for this, but I was curious on
> peoples opinion.  I'm basically trying to figure out what is the best way to
> create componentized views, such as Mason components allows you do reuse
> pieces of the page that are cachable.  Would this basically be done on the
> template level pulling in pieces of various smaller templates into a bigger
> wrapper like template, and forwarding (or perhaps chaining) within the
> controller to gather the data that gets passed into it?   What are peoples
> thoughts on the best way to reuse as many parts of the page as possible when
> certain pieces are used on many pages within the app?

$c->stash(context_menu_template => 'ctx_menu');
$c->stash(context_menu_data => { entries => \@menu_entries });

then in main template

[% INCLUDE $context_menu_template data = context_menu_data %]

and in template 'ctx_menu'

[% data.import;
   FOREACH entry = entries;
   ...
   END; %]

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 



More information about the Catalyst mailing list