Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from szabgab/documentation
Documentation
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
See t/02-complex.t how to generate complex.out from this template. | ||
|
||
<h1>Perl 6 Links | ||
|
||
<ul> | ||
<li><a href="http://rakudo.org/">Rakudo</a></li> | ||
<li><a href="http://perl6.org/">Perl 6</a></li> | ||
</ul> | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
% my (%h) = @_; | ||
See t/02-complex.t how to generate complex.out from this template. | ||
|
||
<h1><%= %h<title> %> | ||
|
||
<ul> | ||
% for %h<pages>.values -> $p { | ||
<li><a href="<%= $p<url> %>"><%= $p<title> %></a></li> | ||
% } | ||
</ul> | ||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use v6; | ||
use Test; | ||
use Template::Mojo; | ||
|
||
|
||
my %params = ( | ||
title => "Perl 6 Links", | ||
pages => [ | ||
{ | ||
"title" => "Rakudo", | ||
"url" => "http://rakudo.org/", | ||
}, | ||
{ | ||
title => 'Perl 6', | ||
url => 'http://perl6.org/', | ||
} | ||
], | ||
); | ||
|
||
plan 1; | ||
|
||
#diag %params.perl; | ||
|
||
my $fh = open "eg/complex.tm", :r; | ||
my $tmpl = $fh.slurp; | ||
#diag $tmpl; | ||
my $output = Template::Mojo.new($tmpl).render(%params); | ||
#diag $output; | ||
|
||
# After changing the template one can save it with this code, | ||
# examine it, and if found correct, keep it as the new expected data | ||
if 0 { | ||
my $out = open "eg/complex.out", :w; | ||
$out.print($output); | ||
$out.close; | ||
} | ||
|
||
my $fh2 = open "eg/complex.out", :r; | ||
my $expected = $fh2.slurp; | ||
is $output, $expected, 'complex'; | ||
|