Skip to content

Commit

Permalink
mention url_for in formats section
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 20, 2015
1 parent c810342 commit d783170
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Mojolicious/Controller.pm
Expand Up @@ -635,7 +635,8 @@ Render content with L<Mojolicious/"renderer"> and emit hooks
L<Mojolicious/"before_render"> as well as L<Mojolicious/"after_render">, or
call L<Mojolicious::Plugin::DefaultHelpers/"reply-E<gt>not_found"> if no
response could be generated, all additional key/value pairs get merged into the
L</"stash">.
L</"stash">. Note that all templates with a C<mojo/*> prefix are reserved for
internal use.
# Render characters
$c->render(text => 'I ♥ Mojolicious!');
Expand Down
8 changes: 8 additions & 0 deletions lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -597,6 +597,14 @@ allowed formats.
# /foo.xml -> {controller => 'foo', action => 'bar', format => 'xml'}
$r->get('/foo' => [format => [qw(rss xml)]])->to('foo#bar');

A C<format> value can also be passed to L<Mojolicious::Controller/"url_for">.

# /foo/bar.txt -> {controller => 'foo', action => 'bar', format => 'txt'}
$r->get('/foo/:action')->to('foo#')->name('baz');

# Generate URL "/foo/bar.txt" for route "baz"
my $url = $c->url_for('baz', action => 'bar', format => 'txt');

Or you can just disable format detection with a special type of restrictive
placeholder, which gets inherited by nested routes, and then re-enable it on
demand.
Expand Down

0 comments on commit d783170

Please sign in to comment.