summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Simões <rsimoes@cpan.org>2012-04-12 17:16:33 -0700
committerRichard Simões <rsimoes@cpan.org>2012-04-12 17:16:33 -0700
commit1f80f14f6ee1a79461e65d3f56dc570adbfc1d53 (patch)
tree96b364be451614525629295b66e154d9d41b36ca
parentBump version to 0.03, change issue tracker and homepage URLs (diff)
parentfix extention and suffix problem (diff)
downloaddancer-template-xslate-1f80f14f6ee1a79461e65d3f56dc570adbfc1d53.tar.gz
Merge pull request #5 from ywatase/fix_extention_problem
fix extension and suffix problem
-rw-r--r--lib/Dancer/Template/Xslate.pm4
-rw-r--r--t/03-cascade.t29
-rw-r--r--t/views/cascade.tx4
-rw-r--r--t/views/cascade_base.tx3
4 files changed, 39 insertions, 1 deletions
diff --git a/lib/Dancer/Template/Xslate.pm b/lib/Dancer/Template/Xslate.pm
index f2446b3..688a645 100644
--- a/lib/Dancer/Template/Xslate.pm
+++ b/lib/Dancer/Template/Xslate.pm
@@ -32,8 +32,10 @@ sub init {
     $self->config->{extension} = $xslate_args{suffix}
         if exists $xslate_args{suffix};
 
+    $self->config->{extension} =~ s/^\.//;
+
     ## avoid 'Text::Xslate: Unknown option(s): extension'
-    $xslate_args{suffix} = delete $xslate_args{extension}
+    $xslate_args{suffix} = '.' . delete $xslate_args{extension}
         if exists $xslate_args{extension};
 
     $self->{driver} = Text::Xslate->new(%xslate_args);
diff --git a/t/03-cascade.t b/t/03-cascade.t
new file mode 100644
index 0000000..5da25e2
--- /dev/null
+++ b/t/03-cascade.t
@@ -0,0 +1,29 @@
+use strict;
+use warnings;
+use Test::More tests => 2;
+use File::Spec::Functions qw(catfile);
+
+use Dancer::Template::Xslate;
+my $engine = Dancer::Template::Xslate->new(
+    config =>
+    {
+        extension => 'tx',
+        path      => [catfile(qw(t views))],
+    },
+);
+
+my $template = catfile(qw(t views cascade.tx));
+my $result = $engine->render($template);
+my $expected = "header\nbody\nfooter\n";
+
+is $result, $expected, "cascade and extension test";
+
+$engine = Dancer::Template::Xslate->new(
+    config =>
+    {
+        suffix => '.tx',
+        path   => [catfile(qw(t views))],
+    },
+);
+$result = $engine->render($template);
+is $result, $expected, "cascade and extension test";
diff --git a/t/views/cascade.tx b/t/views/cascade.tx
new file mode 100644
index 0000000..7317831
--- /dev/null
+++ b/t/views/cascade.tx
@@ -0,0 +1,4 @@
+: cascade cascade_base
+: around body -> {
+body
+: }
diff --git a/t/views/cascade_base.tx b/t/views/cascade_base.tx
new file mode 100644
index 0000000..50703a5
--- /dev/null
+++ b/t/views/cascade_base.tx
@@ -0,0 +1,3 @@
+header
+: block body -> {}
+footer