[Catalyst-commits] r7012 -
trunk/Catalyst-View-Mason/lib/Catalyst/View
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Tue Oct 16 11:17:15 GMT 2007
Author: rafl
Date: 2007-10-16 11:17:15 +0100 (Tue, 16 Oct 2007)
New Revision: 7012
Modified:
trunk/Catalyst-View-Mason/lib/Catalyst/View/Mason.pm
Log:
Refactor logic to determine the component path so people can easier subclass us.
Modified: trunk/Catalyst-View-Mason/lib/Catalyst/View/Mason.pm
===================================================================
--- trunk/Catalyst-View-Mason/lib/Catalyst/View/Mason.pm 2007-10-15 22:01:42 UTC (rev 7011)
+++ trunk/Catalyst-View-Mason/lib/Catalyst/View/Mason.pm 2007-10-16 10:17:15 UTC (rev 7012)
@@ -115,6 +115,29 @@
return $self;
}
+=head2 get_component_path
+
+Returns the component path from $c->stash->{template} or
+$c->request->match or $c->action (depending on the use_match setting).
+
+=cut
+
+sub get_component_path {
+ my ($self, $c) = @_;
+
+ my $component_path = $c->stash->{template};
+
+ unless ($component_path) {
+ $component_path = $self->config->{use_match}
+ ? $c->request->match
+ : $c->action;
+
+ $component_path .= $self->config->{template_extension};
+ }
+
+ return $component_path;
+}
+
=head2 process
Renders the component specified in $c->stash->{template} or $c->request->match
@@ -131,18 +154,9 @@
sub process {
my ($self, $c) = @_;
- my $component_path = $c->stash->{template};
+ my $component_path = $self->get_component_path($c);
+ my $output = $self->render($c, $component_path);
- unless ($component_path) {
- $component_path = $self->config->{use_match}
- ? $c->request->match
- : $c->action;
-
- $component_path .= $self->config->{template_extension};
- }
-
- my $output = $self->render($c, $component_path);
-
if (blessed($output) && $output->isa('HTML::Mason::Exception')) {
chomp $output;
my $error = qq/Couldn't render component "$component_path" - error was "$output"/;
More information about the Catalyst-commits
mailing list