Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mention that controller values get decamelized
  • Loading branch information
kraih committed Aug 19, 2014
1 parent 8e12216 commit 62c3e1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -24,12 +24,19 @@ utilizing multiple template systems and data encoding modules.

Templates can be automatically detected if enough information is provided by
the developer or routes. Template names are expected to follow the
C<name.format.handler> scheme, with C<name> defaulting to C<controller/action>
or the route name, C<format> defaulting to C<html> and C<handler> to C<ep>.
C<template.format.handler> scheme, with C<template> defaulting to
C<controller/action> or the route name, C<format> defaulting to C<html> and
C<handler> to C<ep>.

{controller => 'users', action => 'list'} -> 'users/list.html.ep'
{name => 'foo', format => 'txt'} -> 'foo.txt.ep'
{name => 'foo', handler => 'epl'} -> 'foo.html.epl'
{template => 'foo', format => 'txt'} -> 'foo.txt.ep'
{template => 'foo', handler => 'epl'} -> 'foo.html.epl'

The C<controller> value gets decamelized using L<Mojo::Util/"decamelize"> and
C<-> characters replaced with C</>.

{controller => 'My::Users', action => 'add'} -> 'my/users/add.html.ep'
{controller => 'my-users', action => 'show'} -> 'my/users/show.html.ep'

All templates should be in the C<templates> directories of the application,
which can be customized with L<Mojolicious::Renderer/"paths">, or one of the
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -299,8 +299,8 @@ C<controller#action>.
# /bye -> {controller => 'foo', action => 'bye', mymessage => 'Bye'}
$r->route('/bye')->to('foo#bye', mymessage => 'Bye');

During camelization C<-> gets replaced with C<::>, this allows multi-level
C<controller> hierarchies.
During camelization C<-> characters get replaced with C<::>, this allows
multi-level C<controller> hierarchies.

# / -> MyApp::Controller::Foo::Bar->hi
$r->route('/')->to('foo-bar#hi');
Expand Down

0 comments on commit 62c3e1f

Please sign in to comment.