Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix render file issues #13

Merged
merged 2 commits into from
Jan 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/Text/Haml.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,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 ?
Expand Down Expand Up @@ -1094,7 +1099,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(@_);
}
Expand Down
9 changes: 8 additions & 1 deletion t/render_file.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down