summary refs log tree commit diff
diff options
context:
space:
mode:
authorFayland Lam <fayland@gmail.com>2011-11-25 23:24:40 +0800
committerFayland Lam <fayland@gmail.com>2011-11-25 23:24:40 +0800
commitaf69fc18d7d0ac6dcb00de83e3ef3cfe9d351aeb (patch)
treef835ab37b3b38bff54b6c43b93d8b00fe8aff0d7
parentupdate tests (diff)
downloaddancer-template-xslate-af69fc18d7d0ac6dcb00de83e3ef3cfe9d351aeb.tar.gz
fix for windows and header/footer args
-rw-r--r--lib/Dancer/Template/Xslate.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Dancer/Template/Xslate.pm b/lib/Dancer/Template/Xslate.pm
index 939bbb8..50f2286 100644
--- a/lib/Dancer/Template/Xslate.pm
+++ b/lib/Dancer/Template/Xslate.pm
@@ -6,6 +6,7 @@ use strict;
 use warnings;
 
 use Text::Xslate;
+use Dancer::Config 'setting';
 
 use base 'Dancer::Template::Abstract';
 
@@ -20,11 +21,20 @@ sub init {
         %{$self->config},
     );
 
+    ## set default path for header/footer etc.
+    $args{path} ||= [];
+    my $view_dir = setting('views');
+    push @{$args{path}}, $view_dir unless grep { $_ eq $view_dir } @{$args{path}};
+    
     $_engine = Text::Xslate->new(%args);
 }
 
 sub render {
     my ($self, $template, $tokens) = @_;
+    
+    # absolute filename will never work under Windows even we hard set path as ['/']
+    my $view_dir = setting('views');
+    $template =~ s/^\Q$view_dir\E//;
 
     my $content = eval {
         $_engine->render($template, $tokens)