Created
August 14, 2010 13:06
-
-
Save gfx/524283 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use Encode qw(encode_utf8); | |
| use FindBin qw($Bin); | |
| use Text::Markdown qw(markdown); | |
| use Text::Xslate qw(mark_raw); | |
| my $xslate = Text::Xslate->new( | |
| path => ["$Bin/templates"], | |
| ); | |
| my $books = { | |
| "978-0596520106" => { | |
| name => "Learning Perl", | |
| pages => 352, | |
| }, | |
| "978-0596000271" => { | |
| name => "Programming Perl", | |
| pages => 1092, | |
| }, | |
| "978-0596527242" => { | |
| name => "Mastering Perl", | |
| pages => 352, | |
| }, | |
| "978-0596001735" => { | |
| name => "Perl Best Practices", | |
| pages => 544, | |
| }, | |
| }; | |
| my $see_also = markdown(<<'END_MD'); # an HTML generator | |
| SEE ALSO | |
| ----------------- | |
| * http://perl.com/ | |
| * http://perl.org/ | |
| * http://search.cpan.org/ | |
| END_MD | |
| my $content = $xslate->render("perl.html", { | |
| title => "Perl Books", | |
| books => $books, | |
| see_also => mark_raw($see_also), | |
| }); | |
| print encode_utf8($content); | |
| __END__ |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <title><: $title :></title> | |
| </head> | |
| <body> | |
| <h1><: $title :></h1> | |
| <ol> | |
| : for $books.keys() -> $isbn { | |
| <li><: $books[$isbn].name :> - <: $books[$isbn].pages :> pages / ISBN-13 : <: $isbn :></li> | |
| : } | |
| </ol> | |
| <pre> | |
| $books = | |
| : $books | dump | |
| </pre> | |
| : $see_also # interpolate HTML components | |
| </body> | |
| </html> |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <title>Perl Books</title> | |
| </head> | |
| <body> | |
| <h1>Perl Books</h1> | |
| <ol> | |
| <li>Programming Perl - 1092 pages / ISBN-13 : 978-0596000271</li> | |
| <li>Perl Best Practices - 544 pages / ISBN-13 : 978-0596001735</li> | |
| <li>Learning Perl - 352 pages / ISBN-13 : 978-0596520106</li> | |
| <li>Mastering Perl - 352 pages / ISBN-13 : 978-0596527242</li> | |
| </ol> | |
| <pre> | |
| $books = | |
| ( | |
| '978-0596000271' => { | |
| name => 'Programming Perl', | |
| pages => 1092 | |
| }, | |
| '978-0596001735' => { | |
| name => 'Perl Best Practices', | |
| pages => 544 | |
| }, | |
| '978-0596520106' => { | |
| name => 'Learning Perl', | |
| pages => 352 | |
| }, | |
| '978-0596527242' => { | |
| name => 'Mastering Perl', | |
| pages => 352 | |
| } | |
| ) | |
| </pre> | |
| <h2>SEE ALSO</h2> | |
| <ul> | |
| <li>http://perl.com/</li> | |
| <li>http://perl.org/</li> | |
| <li>http://search.cpan.org/</li> | |
| </ul> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment