X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalystX%2FRoutes.pm;h=67e43ef27730ed4c918eead06972938e30653d6d;hb=2a87778992040c97d1e476cdbf2acafc4e3b1e46;hp=bd9a1313cb2e1a83d1cc0895da9bbedfc4cf8ecc;hpb=07583481bf6503d0edbb3f3cfa1b8513fb6731fd;p=catagits%2FCatalystX-Routes.git diff --git a/lib/CatalystX/Routes.pm b/lib/CatalystX/Routes.pm index bd9a131..67e43ef 100644 --- a/lib/CatalystX/Routes.pm +++ b/lib/CatalystX/Routes.pm @@ -48,10 +48,15 @@ sub _add_route { $attrs->{Chained} = q{/}; } + my $name = $_[0]; + $name =~ s{^/}{}; + # We need to turn the full chain name into a path, since two end points # from two different chains could have the same end point name. - ( my $name = ( $attrs->{Chained} eq '/' ? q{} : $attrs->{Chained} ) . q{/} - . $_[0] ) =~ s/(\W)/'X' . sprintf( '%x', ord($1) )/eg; + $name = ( $attrs->{Chained} eq '/' ? q{} : $attrs->{Chained} ) . q{/} + . $name; + + $name =~ s{/}{|}g; my $meth_base = '__route__' . $name; @@ -74,7 +79,8 @@ sub _add_chain_point { my $meta = shift; my ( $attrs, $sub ) = _process_args( $meta, @_ ); - ( my $name = $_[0] ) =~ s/(\W)/'X' . sprintf('%x', ord(1) )/eg; + my $name = $_[0]; + $name =~ s{/}{|}g; $meta->add_chain_point( $name => [ $attrs, $sub ] ); } @@ -216,7 +222,7 @@ __END__ => sub { ... }; # GET /user/foo - get 'foo' => sub { ... } + get 'foo' => sub { ... }; sub _post { ... } @@ -311,7 +317,7 @@ Use this to declare an action class. By default, this will be L for end points. For other parts of a chain, it simply won't be set. -=head1 Path Generation +=head1 PATH GENERATION All of the end point function (C, C, etc.) take a path as the first argument. By default, this will be used as the C for the chain. You @@ -321,12 +327,24 @@ is essentially ignored (but still required). Note that it is legitimate to pass the empty string as the name for a chain's end point. +If the end point's name does not start with a slash, it will be prefixed with +the controller's namespace. + If you don't specify a C value for an end point, then it will use the root URI, C, as the root of the chain. By default, no arguments are specified for a chain's end point, meaning it will accept any number of arguments. +=head1 CAVEATS + +When adding subroutines for end points to your controller, a name is generated +for each subroutine based on the chained path to the subroutine. Some +template-based views will automatically pick a template based on the +subroutine's name if you don't specify one explicitly. This won't work very +well with the bizarro names that this module generates, so you are strongly +encouraged to specify a template name explicitly. + =head1 BUGS Please report any bugs or feature requests to