* On Fri, Mar 07 2008, Matthias Zeichmann wrote: > On Thu, Mar 6, 2008 at 11:11 PM, David Jack Wange Olrik <[EMAIL PROTECTED]> > wrote: >> Here is a small patch for Catalyst::View::Mason. >> >> When setting $c->stash->{template}, template_extension was not added >> to the component path. In my opinion this should always be added, so >> one can easily change the view without having to provide extra logic >> that sets the template extension according to the current view. > > C:V:TT behaves exactly the same way [0] and i suspect its not the only > view that does > > my $template = $c->stash->{template} > || $c->action . $self->config->{TEMPLATE_EXTENSION};
This is really the only thing that makes sense. To do what David wanted would have to use a heuristic to determine whether $c->stash->{template} is the actual template name, or the template name minus the extension. By definition, that's never going to work. Fortunately, it's easy to implement the behavior in your own app: package MyApp::View::Whatever; use base qw/Catalyst::Component::ACCEPT_CONTEXT Catalyst::View::Whatever/; sub set_template_name { my ($self, $name) = @_; my $extension = $self->{TEMPLATE_EXTENSION}; given($self->context->request->path){ when(/OH HAI/){ $extension = 'something-else'; } } return $self->context->stash->{template} = "$name.$extension"; } Then you can do this: sub action :Path('OH_HAI') { my ($self, $c) = @_; ... $c->view('Whatever')->set_template_name('name-without-extension'); } Then $c->stash->{template} will be 'name-without-extension.something-else'. Regards, Jonathan Rockway _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/