Skip to content

Commit

Permalink
more template tests and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 12, 2012
1 parent e585f5d commit 9caf5a8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,5 +1,7 @@

3.07 2012-07-12
- Improved documentation.
- Improved tests.
- Fixed small bug in Mojolicious::Plugin::EPRenderer that prevented code to
be added to all templates.

Expand Down
13 changes: 9 additions & 4 deletions lib/Mojo/Template.pm
Expand Up @@ -403,12 +403,13 @@ L<Mojo::ByteStream> objects are always excluded from automatic escaping.
<%= Mojo::ByteStream->new('<div>excluded!</div>') %>
Newlines can be escaped with a backslash.
Newline characters can be escaped with a backslash.
This is <%= 1 + 1 %> a\
single line
And a backslash in front of a newline can be escaped with another backslash.
And a backslash in front of a newline character can be escaped with another
backslash.
This will <%= 1 + 1 %> result\\
in multiple\\
Expand Down Expand Up @@ -472,7 +473,9 @@ Activate automatic XML escaping.
my $code = $mt->append;
$mt = $mt->append('warn "Processed template"');
Append Perl code to compiled template.
Append Perl code to compiled template. Note that this code should not contain
newline characters, or line numbers in error messages might end up being
wrong.
=head2 C<capture_end>
Expand Down Expand Up @@ -566,7 +569,9 @@ Namespace used to compile templates, defaults to C<Mojo::Template::SandBox>.
my $code = $mt->prepend;
$mt = $mt->prepend('my $self = shift;');
Prepend Perl code to compiled template.
Prepend Perl code to compiled template. Note that this code should not contain
newline characters, or line numbers in error messages might end up being
wrong.
=head2 C<replace_mark>
Expand Down
5 changes: 3 additions & 2 deletions lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -116,12 +116,13 @@ Only L<Mojo::ByteStream> objects are excluded from automatic escaping.

<%= Mojo::ByteStream->new('<p>test</p>') %>

Newlines can be escaped with a backslash.
Newline characters can be escaped with a backslash.

This is <%= 1 + 1 %> a\
single line

And a backslash in front of a newline can be escaped with another backslash.
And a backslash in front of a newline character can be escaped with another
backslash.

This will <%= 1 + 1 %> result\\
in multiple\\
Expand Down
5 changes: 3 additions & 2 deletions t/mojolicious/twinkle_lite_app.t
Expand Up @@ -25,6 +25,7 @@ my $twinkle = {
escape_mark => '*',
expression_mark => '*',
line_start => '.',
namespace => 'TwinkleSandBoxTest',
prepend => 'no warnings "redefine"; sub bar { "bar!" }',
tag_end => '**',
tag_start => '**',
Expand Down Expand Up @@ -71,7 +72,7 @@ my $t = Test::Mojo->new;

# GET /
$t->get_ok('/')->status_is(200)
->content_like(qr/testHello <sebastian>!bar!123/);
->content_like(qr/testHello <sebastian>!bar! TwinkleSandBoxTest123/);

# GET /advanced
$t->get_ok('/advanced')->status_is(200)
Expand Down Expand Up @@ -102,7 +103,7 @@ __DATA__
@@ index.foo.twinkle
. layout 'twinkle';
Hello *** $name **!\
*** bar **\
*** bar ** *** __PACKAGE__ **\
@@ layouts/twinkle.foo.ep
test<%= content %>123\
Expand Down

0 comments on commit 9caf5a8

Please sign in to comment.