Skip to content

Commit

Permalink
mention subdirectory handling in rendering guide
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 29, 2013
1 parent 88c3814 commit 38e8d8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

4.17 2013-06-26
4.17 2013-06-29
- Fixed Mojo::Transaction::WebSocket to generate RFC 6455 compliant
Sec-WebSocket-Key headers. (josh)

Expand Down
16 changes: 10 additions & 6 deletions lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -175,25 +175,29 @@ rendering when a non-blocking operation has to be performed first.

=head2 Rendering templates

The renderer will always try to detect the right template but you can also
use the C<template> stash value to render a specific one.
The renderer will always try to detect the right template, but you can also
use the C<template> stash value to render a specific one. Everything before
the last slash will be interpreted as the subdirectory path in which to find
the template.

$self->render(template => 'foo/bar');
# foo/bar/baz.*.*
$self->render(template => 'foo/bar/baz');

Choosing a specific C<format> and C<handler> is just as easy.

$self->render(template => 'foo/bar', format => 'txt', handler => 'epl');
# foo/bar/baz.txt.epl
$self->render(template => 'foo/bar/baz', format => 'txt', handler => 'epl');

Because rendering a specific template is the most common task it also has a
shortcut.

$self->render('foo/bar');
$self->render('foo/bar/baz');

If you're not sure in advance if a template actually exists, you can also use
the method L<Mojolicious::Controller/"render_maybe"> to try multiple
alternatives.

$self->render_maybe('localized/bar') or $self->render('foo/bar');
$self->render_maybe('localized/baz') or $self->render('foo/bar/baz');

=head2 Rendering inline templates

Expand Down

0 comments on commit 38e8d8f

Please sign in to comment.