Skip to content

Commit

Permalink
mention that begin/end keywords are part of the surrounding tag
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 28, 2015
1 parent ec40a50 commit 4cd34c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion lib/Mojo/Template.pm
Expand Up @@ -378,7 +378,9 @@ backslash.
lines
You can capture whole template blocks for reuse later with the C<begin> and
C<end> keywords.
C<end> keywords. Just be aware that both keywords are part of the surrounding
tag and not actual Perl code, so there can only be whitespace after C<begin>
and before C<end>.
<% my $block = begin %>
<% my $name = shift; =%>
Expand Down
19 changes: 9 additions & 10 deletions lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -350,15 +350,12 @@ and controller code.
# Controller
my $serialized = $c->dumper([1, 2, 3]);

The helper L<Mojolicious::Plugin::DefaultHelpers/"dumper"> for example will use
L<Data::Dumper> to serialize whatever data structure you pass it, this can be
very useful for debugging. We differentiate between default helpers which are
more general purpose like C<dumper> and tag helpers, which are template
specific and mostly used to generate HTML tags.

%= link_to 'http://mojolicio.us' => begin
Mojolicious
% end
We differentiate between default helpers, which are more general purpose like
L<Mojolicious::Plugin::DefaultHelpers/"dumper">, and tag helpers like
L<Mojolicious::Plugin::TagHelpers/"link_to">, which are template specific and
mostly used to generate HTML tags.

%= link_to Mojolicious => 'http://mojolicio.us'

In controllers you can also use the method L<Mojolicious::Controller/"helpers">
to fully qualify helper calls and ensure that they don't conflict with existing
Expand Down Expand Up @@ -637,7 +634,9 @@ another.

It's never fun to repeat yourself, that's why you can build reusable template
blocks in C<ep> that work very similar to normal Perl functions, with the
C<begin> and C<end> keywords.
C<begin> and C<end> keywords. Just be aware that both keywords are part of the
surrounding tag and not actual Perl code, so there can only be whitespace after
C<begin> and before C<end>.

use Mojolicious::Lite;

Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Plugin/DefaultHelpers.pm
Expand Up @@ -309,7 +309,8 @@ exception gets thrown in one of the steps, breaking the chain.
%= dumper {some => 'data'}
Dump a Perl data structure with L<Mojo::Util/"dumper">.
Dump a Perl data structure with L<Mojo::Util/"dumper">, very useful for
debugging.
=head2 extends
Expand Down

0 comments on commit 4cd34c5

Please sign in to comment.