Skip to content

Instantly share code, notes, and snippets.

@jmmills
Created June 17, 2015 19:35
Show Gist options
  • Select an option

  • Save jmmills/d80c405f9576f4f8fdb0 to your computer and use it in GitHub Desktop.

Select an option

Save jmmills/d80c405f9576f4f8fdb0 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use 5.16.0;
use Test::More;
use Carp::Always;
our $TEST_STRING = 'this is a test';
package main;
use_ok 'Template';
use_ok 'Template::Context';
isa_ok my $p = Foo::Provider->new(), 'Foo::Provider';
isa_ok my $c = Template::Context->new({LOAD_TEMPLATES=>[$p]}), 'Template::Context';
isa_ok my $t = Template->new(CONTEXT => $c), 'Template';
my $template = '[%- INCLUDE foo -%]';
ok my $result = $t->context->process($template);
is $result, $TEST_STRING;
done_testing();
1;
package Foo::Provider;
use base 'Template::Provider';
sub _template_content {
my $self = shift;
my $path = shift;
# return the same template no matter what
return $TEST_STRING;
}
sub _template_modified {
my $self = shift;
my $path = shift;
return time
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment