summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorFayland Lam <fayland@gmail.com>2011-11-27 11:52:09 +0800
committerFayland Lam <fayland@gmail.com>2011-11-27 11:52:09 +0800
commit9b7abdb3f6b7e819e83dccb7bc19e9cf651442ff (patch)
treeb073eab21ee90c9282a4b91a70eea714afad32d2 /lib
parentfix a warnings (diff)
downloaddancer-template-xslate-9b7abdb3f6b7e819e83dccb7bc19e9cf651442ff.tar.gz
fix Win32 path
Diffstat (limited to 'lib')
-rw-r--r--lib/Dancer/Template/Xslate.pm6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Dancer/Template/Xslate.pm b/lib/Dancer/Template/Xslate.pm
index 7f5632c..d3b062b 100644
--- a/lib/Dancer/Template/Xslate.pm
+++ b/lib/Dancer/Template/Xslate.pm
@@ -7,6 +7,7 @@ use warnings;
 
 use Text::Xslate;
 use Dancer::App;
+use File::Spec;
 
 use base 'Dancer::Template::Abstract';
 
@@ -39,7 +40,10 @@ sub render {
     
     # absolute filename will never work under Windows even we hard set path as ['/']
     my $view_dir = Dancer::App->current->setting('views');
-    $template =~ s/^\Q$view_dir\E// if $view_dir;
+    if ( $view_dir ) {
+        $view_dir = File::Spec->catdir( File::Spec->splitdir($view_dir) ) if $^O eq 'MSWin32'; # dirty Win32 fixes for / \
+        $template =~ s/^\Q$view_dir\E//;
+    }
 
     my $content = eval {
         $_engine->render($template, $tokens)