Created
September 1, 2010 08:12
-
-
Save anonymous/560392 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git i/t/mojo/template.t w/t/mojo/template.t | |
index 869fcb2..db281e6 100644 | |
--- i/t/mojo/template.t | |
+++ w/t/mojo/template.t | |
@@ -23,7 +23,7 @@ package main; | |
use strict; | |
use warnings; | |
-use Test::More tests => 95; | |
+use Test::More tests => 96; | |
use File::Spec; | |
use File::Temp; | |
@@ -427,6 +427,25 @@ $output = $mt->render(<<'EOF'); | |
EOF | |
is($output, "<html>\n1234</html>\n", 'clean multiline loop'); | |
+# Recursive template call | |
+$mt = Mojo::Template->new; | |
+$output = $mt->render(<<'EOF'); | |
+<% sub list { =%> | |
+<% my $t = shift; =%> | |
+<ul> | |
+<% for my $n (@$t) { =%> | |
+<li><%= $n->{name} =%> | |
+<% if (exists($n->{tree})) { =%> | |
+<%= list($n->{tree}) =%> | |
+<% } =%> | |
+</li> | |
+<% } =%> | |
+</ul> | |
+<% } =%> | |
+<%= list([{id=>1,name=>"root",tree=>[{id=>2,name=>"le"}]}]) %> | |
+EOF | |
+is($output, "<ul><li>root<ul><li>le</li></ul></li></ul>", 'recursive template call'); | |
+ | |
# Escaped line ending | |
$mt = Mojo::Template->new; | |
$output = $mt->render(<<'EOF'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment