Skip to content

Commit

Permalink
slightly less verbose examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 6, 2016
1 parent c889cf9 commit e535cbc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/Mojo/Template.pm
Expand Up @@ -317,7 +317,7 @@ Mojo::Template - Perl-ish templates!
# Use Perl modules
my $mt = Mojo::Template->new;
my $output = $mt->render(<<'EOF');
say $mt->render(<<'EOF');
% use Time::Piece;
<!DOCTYPE html>
<html>
Expand All @@ -326,26 +326,23 @@ Mojo::Template - Perl-ish templates!
<body>Time: <%= $now->hms %></body>
</html>
EOF
say $output;
# Render with arguments
my $output = $mt->render(<<'EOF', 23, 'Arguments');
say $mt->render(<<'EOF', 23, 'Arguments');
% my ($num, $title) = @_;
<!DOCTYPE html>
<html>
<head><title><%= $title %></title></head>
<body>
foo <% my $i = $num + 2; %>
% for (1 .. 23) {
* some text <%= $i++ %>
% for my $i (1 .. $num) {
* some text <%= $i %>
% }
</body>
</html>
EOF
say $output;
# Render with named variables
my $output = $mt->vars(1)->render(<<'EOF', {title => 'Variables'});
say $mt->vars(1)->render(<<'EOF', {title => 'Variables'});
<!DOCTYPE html>
<html>
<head><title><%= $title %></title></head>
Expand All @@ -354,7 +351,6 @@ Mojo::Template - Perl-ish templates!
</body>
</html>
EOF
say $output;
=head1 DESCRIPTION
Expand Down

0 comments on commit e535cbc

Please sign in to comment.