[Catalyst] :Template() Attribute

Matt S Trout dbix-class at trout.me.uk
Mon Jun 18 14:44:22 GMT 2007


On Mon, Jun 18, 2007 at 09:28:36AM +0000, Zbigniew Lukasiak wrote:
> When we are at this View refactoring.  When changing the template you
> need to put the whole path on stash ( $c->stash( template =
> template_path/template.tt) ).  What I would propose is that the view
> automatically used the $c->action->namespace as the template_path - so
> that you would not need to specify the full path - only the template
> name.
> 
> This would mean less typing in most common case but also should be
> useful when inheriting from a base controller - since it would
> automatically adjust the template paths - and that is what you need in
> most cases as well.  The ideal would be if it would search the
> template directories of respective controller classes in the
> inheritance tree - but I have no idea how to accomplish that.

Some code somewhere that did

my @parts = split('/',$c->action->namespace);
my @paths = map { join('/', at parts[0..$_]) } 0 .. $#parts;
$c->stash(additional_template_paths => \@paths);

would probably do the trick for this.

I'm not yet 100% convinced that's how we should default it though. I think
there may be better defaults :)

-- 
      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