Permalink
Browse files

Merge pull request #3 from szabgab/master

META.info and some POD
  • Loading branch information...
masak committed Jul 2, 2012
2 parents 3e1de39 + 77eea3f commit e8b659c871155fc007999ed2c22a56edab75934c
Showing with 93 additions and 1 deletion.
  1. +1 −1 META.info
  2. +19 −0 eg/index.pl6
  3. +18 −0 eg/templates/index.tmpl
  4. +55 −0 lib/HTML/Template.pm
View
@@ -4,5 +4,5 @@
"description" : "A simple almost-port of CPAN's HTML::Template to Perl 6",
"depends" : [ ],
"repo-type" : "git",
- "repo-url" : "git://github.com/masak/html-template.git"
+ "source-url" : "git://github.com/masak/html-template.git"
}
View
@@ -0,0 +1,19 @@
+ use v6;
+
+ use HTML::Template;
+
+ my %params = (
+ title => 'Hello Perl 6 world',
+ authors => Array.new(
+ { name => 'Ilya' },
+ { name => 'Moritz' },
+ { name => 'Lyle' },
+ { name => 'Carl' },
+ { name => 'Johan' },
+ ),
+ );
+
+ my $ht = HTML::Template.from_file("templates/index.tmpl");
+ $ht.with_params(%params);
+ print $ht.output;
+
View
@@ -0,0 +1,18 @@
+ <html><head><title><TMPL_VAR title></head>
+ <body>
+ <h1><TMPL_VAR title>
+
+ <ul>
+ <TMPL_LOOP authors>
+ <li><TMPL_VAR name></li>
+ </TMPL_LOOP>
+ </ul>
+
+ <TMPL_IF error>
+ <div id="error">Some error happened</div>
+ </TMPL_IF>
+
+ </body>
+ </html>
+
+
View
@@ -3,6 +3,61 @@ class HTML::Template;
use Text::Escape;
use HTML::Template::Grammar;
+=begin pod
+
+=head1 NAME
+
+HTML::Template - A simple templating system based on the HTML::Template of Perl 5
+
+=head1 SYNOPSIS
+
+eg/index.pl6 looks like this:
+
+ use v6;
+
+ use HTML::Template;
+
+ my %params = (
+ title => 'Hello Perl 6 world',
+ authors => Array.new(
+ { name => 'Ilya' },
+ { name => 'Moritz' },
+ { name => 'Lyle' },
+ { name => 'Carl' },
+ { name => 'Johan' },
+ ),
+ );
+
+ my $ht = HTML::Template.from_file("templates/index.tmpl");
+ $ht.with_params(%params);
+ print $ht.output;
+
+eg/templates/index.tmpl looks like this:
+
+ <html><head><title><TMPL_VAR title></head>
+ <body>
+ <h1><TMPL_VAR title>
+
+ <ul>
+ <TMPL_LOOP authors>
+ <li><TMPL_VAR name></li>
+ </TMPL_LOOP>
+ </ul>
+
+ <TMPL_IF error>
+ <div id="error">Some error happened</div>
+ </TMPL_IF>
+
+ </body>
+ </html>
+
+
+=head1 AUTHOR
+
+Carl Masak
+
+=end pod
+
has $.in;
has %!params;
has %!meta;

0 comments on commit e8b659c

Please sign in to comment.