Navigation Menu

Skip to content

Commit

Permalink
better template tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 11, 2012
1 parent 96b605e commit d7bd288
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Changes
@@ -1,5 +1,9 @@
This file documents the revision history for Perl extension Mojolicious.

2.96 2012-05-11
- Improved documentation.
- Improved tests.

2.95 2012-05-10
- Improved documentation.
- Fixed bug that caused inactivity timeouts to be logged too often.
Expand Down
10 changes: 7 additions & 3 deletions lib/Mojo/Template.pm
Expand Up @@ -286,9 +286,8 @@ sub parse {
}

sub render {
my $self = shift;
my $e = $self->parse(shift)->build->compile;
return $e ? $e : $self->interpret(@_);
my $self = shift->parse(shift)->build;
return $self->compile || $self->interpret(@_);
}

sub render_file {
Expand Down Expand Up @@ -674,6 +673,11 @@ Compile template.
Interpret template.
# Reuse template
say $mt->render('Result <%= $_[0] + $_[1] %>', 1, 1);
say $mt->interpret(2, 2);
say $mt->interpret(3, 3);
=head2 C<parse>
$mt = $mt->parse($template);
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -34,7 +34,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Leaf Fluttering In Wind';
our $VERSION = '2.95';
our $VERSION = '2.96';

# "These old doomsday devices are dangerously unstable.
# I'll rest easier not knowing where they are."
Expand Down
6 changes: 5 additions & 1 deletion t/mojo/template.t
Expand Up @@ -17,7 +17,7 @@ use Mojo::Base -strict;

use utf8;

use Test::More tests => 202;
use Test::More tests => 204;

# "When I held that gun in my hand, I felt a surge of power...
# like God must feel when he's holding a gun."
Expand Down Expand Up @@ -789,6 +789,10 @@ $output = $mt->render(<<'EOF', 'test', {foo => 'bar'});
</html>
EOF
is $output, "<html>\ntest bar\n</html>\n", 'arguments';
is $mt->interpret('tset', {foo => 'baz'}), "<html>\ntset baz\n</html>\n",
'arguments again';
is $mt->interpret('tset', {foo => 'yada'}), "<html>\ntset yada\n</html>\n",
'arguments again';

# Ugly multiline loop
$mt = Mojo::Template->new;
Expand Down

0 comments on commit d7bd288

Please sign in to comment.