Browse files

suppor Text::MicroTemplate::Extended

  • Loading branch information...
1 parent beef318 commit 8100860e215515d9bd1dad8db3dd3cefd54749f3 @tokuhirom committed Aug 7, 2010
Showing with 42 additions and 0 deletions.
  1. +20 −0 lib/Tfall/Text/MicroTemplate/Extended.pm
  2. +22 −0 t/020_templates/10_tmte.t
View
20 lib/Tfall/Text/MicroTemplate/Extended.pm
@@ -0,0 +1,20 @@
+package Tfall::Text::MicroTemplate::Extended;
+use strict;
+use warnings;
+use Text::MicroTemplate::Extended;
+
+sub new {
+ my $class = shift;
+ my $mtf = Text::MicroTemplate::Extended->new(@_);
+ bless {
+ mtf => $mtf,
+ }, $class;
+}
+
+sub render {
+ my ($self, $stuff, @args) = @_;
+ return $self->{mtf}->render($stuff, @args);
+}
+
+1;
+
View
22 t/020_templates/10_tmte.t
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+use Test::Requires 'Text::MicroTemplate::Extended';
+use Test::More;
+use Tfall;
+use Tfall::Text::MicroTemplate::Extended;
+
+{
+ eval {
+ my $tmpl = Tfall::Text::MicroTemplate::Extended->new();
+ is $tmpl->render('t/tmpl/unknown.mt', 'john'), undef;
+ };
+ ok $@;
+}
+
+{
+ my $tmpl = Tfall::Text::MicroTemplate::Extended->new(include_path => ['t/tmpl']);
+ is $tmpl->render('foo', 'john'), "hello, john.\n";
+}
+
+done_testing;
+

0 comments on commit 8100860

Please sign in to comment.