Group :: Development/Perl
RPM: perl-Dancer-Template-Xslate
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: perl-Dancer-Template-Xslate-0.01-alt1.patch
Download
Download
lib/Dancer/Template/Xslate.pm | 12 ++++++++++++
t/01-main.t | 2 +-
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/lib/Dancer/Template/Xslate.pm b/lib/Dancer/Template/Xslate.pm
index 673ca10..8708024 100644
--- a/lib/Dancer/Template/Xslate.pm
+++ b/lib/Dancer/Template/Xslate.pm
@@ -13,6 +13,7 @@ use Text::Xslate;
use base 'Dancer::Template::Abstract';
my $_engine;
+my $_views_path;
sub init {
my $self = shift;
@@ -21,12 +22,23 @@ sub init {
%{$self->config},
);
+ my $app = Dancer::App->current;
+ $_views_path = $app->setting('views');
+
+ $args{'path'} = $_views_path;
+
$_engine = Text::Xslate->new(%args);
}
sub render {
my ($self, $template, $tokens) = @_;
+ if (index($template, $_views_path) != 0) {
+ die "Template $template not found under view paths";
+ }
+
+ substr($template, 0, length($_views_path)) = "";
+
my $content = eval {
$_engine->render($template, $tokens)
};
diff --git a/t/01-main.t b/t/01-main.t
index 97682ed..754ddfa 100644
--- a/t/01-main.t
+++ b/t/01-main.t
@@ -2,7 +2,7 @@ use strict;
use warnings;
use Test::More tests => 2;
use Dancer::FileUtils 'path';
-
+use Dancer::App;
use Dancer::Template::Xslate;
my $engine;