Created
June 17, 2015 19:35
-
-
Save jmmills/d80c405f9576f4f8fdb0 to your computer and use it in GitHub Desktop.
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
| 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