Created
December 10, 2012 15:14
-
-
Save unixmonkey/4251165 to your computer and use it in GitHub Desktop.
Perl Template Toolkit example using __DATA__ as template
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 Template; | |
| my @coordinates = [ | |
| 11, 22, 39, 393, 102, 102 | |
| ]; | |
| my $vars = { | |
| title => 'Hello, World!', | |
| coordinates => @coordinates, | |
| }; | |
| my $template = Template->new(); | |
| $template->process(\*DATA, $vars) || die $template->error(), "\n"; | |
| __DATA__ | |
| Content-type: text/html | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>[% title %]</title> | |
| </head> | |
| <body> | |
| [% FOREACH coordinate IN coordinates %] | |
| <li>[% coordinate %]</li> | |
| [% END %] | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment