Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
show an inline template as well
  • Loading branch information
kraih committed Nov 22, 2015
1 parent 57e3f61 commit 81762ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -158,8 +158,8 @@ works with all built-in web servers.
$ ./script/my_app prefork -P /tmp/first.pid -l http://*:8080?reuse=1
Server available at http://127.0.0.1:8080

All you have to do is start a second web server listening to the same port and
stop the first web server gracefully afterwards.
All you have to do, is to start a second web server listening to the same port,
and stop the first web server gracefully afterwards.

$ ./script/my_app prefork -P /tmp/second.pid -l http://*:8080?reuse=1
Server available at http://127.0.0.1:8080
Expand Down
22 changes: 13 additions & 9 deletions lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -947,9 +947,9 @@ L<Mojolicious::Validator::Validation/"error">.
=head2 Cross-site request forgery

CSRF is a very common attack on web applications that trick your logged in
users to submit forms they did not intend to send. All you have to do to
users to submit forms they did not intend to send. All you have to do, to
protect your users from this, is to add an additional hidden field to your
forms with L<Mojolicious::Plugin::TagHelpers/"csrf_field"> and validate it with
forms with L<Mojolicious::Plugin::TagHelpers/"csrf_field">, and validate it with
L<Mojolicious::Validator::Validation/"csrf_protect">.

use Mojolicious::Lite;
Expand Down Expand Up @@ -1373,8 +1373,8 @@ L<Mojo::Template> contains the whole list of available options.
=head2 Adding your favorite template system

Maybe you would prefer a different template system than C<ep>, and there is not
already a plugin on CPAN for your favorite one, all you have to do is add a new
C<handler> with L<Mojolicious::Renderer/"add_handler"> when C<register> is
already a plugin on CPAN for your favorite one. All you have to do, is to add a
new C<handler> with L<Mojolicious::Renderer/"add_handler"> when C<register> is
called.

package Mojolicious::Plugin::MyRenderer;
Expand Down Expand Up @@ -1410,20 +1410,24 @@ called.
1;

An C<inline> template, if provided by the user, will be passed along with the
options. The C<templates> directories of the application can be searched with
L<Mojolicious::Renderer/"template_path">, and the C<DATA> sections with
L<Mojolicious::Renderer/"get_data_template">.
options. To search the C<templates> directories of the application, you can use
L<Mojolicious::Renderer/"template_path">, and
L<Mojolicious::Renderer/"get_data_template"> to search the C<DATA> sections.

use Mojolicious::Lite;

plugin 'MyRenderer';

get '/' => 'index';
# Render an inline template
get '/inline' => {inline => '...', handler => 'mine'};

# Render a template from the DATA section
get '/data' => {template => 'test'};

app->start;
__DATA__

@@ index.html.mine
@@ test.html.mine
...

=head2 Adding a handler to generate binary data
Expand Down

0 comments on commit 81762ff

Please sign in to comment.