Permalink
Browse files

Merge pull request #13 from carloslima/fix-render_file-issues

Fix render file issues
  • Loading branch information...
vti committed Jan 1, 2013
2 parents 03b01a6 + 7ec25fa commit 3c6de741f9273f42ac0017e1c3b624dbdd837fc5
Showing with 14 additions and 2 deletions.
  1. +6 −1 lib/Text/Haml.pm
  2. +8 −1 t/render_file.t
View
@@ -1036,6 +1036,11 @@ sub _fullpath {
my $self = shift;
my $path = shift;
+ if (File::Spec->file_name_is_absolute($path) and -r $path) {
+ $self->fullpath($path);
+ return;
+ }
+
for my $p (@{$self->path}) {
my $fullpath = File::Spec->catfile($p, $path);
if (-r $fullpath) { # is readable ?
@@ -1093,7 +1098,7 @@ sub _eq_mtime {
sub _interpret_cached {
my $self = shift;
- my $compiled = require $self->cache_path;
+ my $compiled = do $self->cache_path;
$self->compiled($compiled);
return $self->interpret(@_);
}
View
@@ -5,7 +5,7 @@ use warnings;
use Text::Haml;
-use Test::More tests => 6;
+use Test::More tests => 9;
use IO::File;
use URI::Escape ();
@@ -37,6 +37,9 @@ my $expected1 = do { local $/; <$file> };
$file->close;
is($output, $expected1);
+$output = $haml->render_file( File::Spec->rel2abs(File::Spec->catfile('t', 'render1.haml')), title => 'RENDER_FILE_TEST');
+is($output, $expected1);
+
my $uri_escaped = URI::Escape::uri_escape($tempdir);
my $cache_dir = File::Spec->catdir($tempdir, $uri_escaped);
note($cache_dir);
@@ -67,6 +70,10 @@ $haml = Text::Haml->new(
$output = $haml->render_file('render.haml', title => 'RENDER_FILE_TEST');
# same output test 1
is($output, $expected1);
+# rendering same file again works just the same
+$output = $haml->render_file('render.haml', title => 'RENDER_FILE_TEST');
+is($output, $expected1);
+is($haml->error,undef);
$haml = Text::Haml->new(
path => $tempdir,

0 comments on commit 3c6de74

Please sign in to comment.