Skip to content

Instantly share code, notes, and snippets.

Created August 2, 2011 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1119532 to your computer and use it in GitHub Desktop.
Save anonymous/1119532 to your computer and use it in GitHub Desktop.
use v6;
# my @files = dir 'input';
class Entry {
has $.filename;
has $.title;
has $.date;
has $.text;
method gen {
my $template = slurp('./templates/index');
$template ~~ s/<title>/<h1>$!title<\/h1>/;
$template ~~ s/<text>/$!text/;
my $fh = open('./output/$!filename.html/');
$fh.print($template);
$fh.close;
say "Generated $!filename.html.";
}
}
my $firstpost = Entry.new(
filename => 'newfile',
title => 'writing a website in perl6',
date => '2011-08-01',
text => '<p>woo, go perl6!</p>'
);
$firstpost.gen;
<html>
<body>
<title>
<br/>
<text>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment