Permalink
Browse files

Fixes render_file to work when given a fullpath

  • Loading branch information...
Carlos Lima
Carlos Lima committed Nov 30, 2012
1 parent e5d286c commit 7ec25fad6c06435cdbd3c8fddc1d3db7ca7cba5e
Showing with 9 additions and 1 deletion.
  1. +5 −0 lib/Text/Haml.pm
  2. +4 −1 t/render_file.t
View
@@ -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 ?
View
@@ -5,7 +5,7 @@ use warnings;
use Text::Haml;
-use Test::More tests => 8;
+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);

3 comments on commit 7ec25fa

@tommystanton

This comment has been minimized.

Show comment Hide comment
@tommystanton

tommystanton Apr 22, 2013

This fixes my problem! :) My problem is inside of a Dancer application, via Dancer::Template::Haml. An absolute path is being passed to _fullpath().

I hope to see a new release on the CPAN soon, with this change included.

This fixes my problem! :) My problem is inside of a Dancer application, via Dancer::Template::Haml. An absolute path is being passed to _fullpath().

I hope to see a new release on the CPAN soon, with this change included.

@vti

This comment has been minimized.

Show comment Hide comment
@vti

vti Apr 22, 2013

Owner

On it's way!

Owner

vti replied Apr 22, 2013

On it's way!

@tommystanton

This comment has been minimized.

Show comment Hide comment
@tommystanton

tommystanton Apr 22, 2013

I see it coming. Thanks, Viacheslav! :)

I see it coming. Thanks, Viacheslav! :)

Please sign in to comment.