[Catalyst-commits] r8761 - in trunk/Catalyst-View-XSLT: lib/Catalyst/View t t/lib

janus at dev.catalyst.perl.org janus at dev.catalyst.perl.org
Sat Dec 6 15:33:43 GMT 2008


Author: janus
Date: 2008-12-06 15:33:43 +0000 (Sat, 06 Dec 2008)
New Revision: 8761

Added:
   trunk/Catalyst-View-XSLT/t/09_template_string.t
Modified:
   trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT.pm
   trunk/Catalyst-View-XSLT/t/lib/TestApp.pm
Log:
fix support for xsl template strings and add a corresponding test

Modified: trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT.pm
===================================================================
--- trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT.pm	2008-12-06 05:25:30 UTC (rev 8760)
+++ trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT.pm	2008-12-06 15:33:43 UTC (rev 8761)
@@ -221,7 +221,7 @@
 sub render {
     my ( $self, $c, $template, $args ) = @_;
 
-    unless ( -e $template) {
+    unless ( $template =~ m/\</ || -e $template ) {
         my ($tmplFullPath, $error) = $self->_searchInIncPath($c, $template);
 
         if (defined $error) {

Added: trunk/Catalyst-View-XSLT/t/09_template_string.t
===================================================================
--- trunk/Catalyst-View-XSLT/t/09_template_string.t	                        (rev 0)
+++ trunk/Catalyst-View-XSLT/t/09_template_string.t	2008-12-06 15:33:43 UTC (rev 8761)
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+use Test::More tests => 5;
+
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use lib "$FindBin::Bin/lib";
+
+use_ok('Catalyst::Test', 'TestApp');
+
+my $view = 'XML::LibXSLT';
+
+my $response;
+ok(($response = request("/test_template_string?view=$view"))->is_success, 'request ok');
+is($response->content, TestApp->config->{default_message}, 'message ok');
+
+my $message = scalar localtime;
+my $xml = "<dummy-root>$message</dummy-root>";
+ok(($response = request("/test_template_string?view=$view&message=$message"))->is_success, 'request with message ok');
+is($response->content, $message, 'message ok');
+

Modified: trunk/Catalyst-View-XSLT/t/lib/TestApp.pm
===================================================================
--- trunk/Catalyst-View-XSLT/t/lib/TestApp.pm	2008-12-06 05:25:30 UTC (rev 8760)
+++ trunk/Catalyst-View-XSLT/t/lib/TestApp.pm	2008-12-06 15:33:43 UTC (rev 8761)
@@ -81,6 +81,29 @@
     $c->stash->{xml} = "<dummy-root>$out</dummy-root>";
 }
 
+sub test_template_string : Local {
+    my ($self, $c) = @_;
+
+    my $message = $c->request->param('message') || $c->config->{default_message};
+
+    $c->stash->{xml} = "<dummy-root>$message</dummy-root>";
+
+    $c->stash->{template} = <<'EOXSL';
+<?xml version="1.0"?>
+<xsl:stylesheet 
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+	version="1.0">
+
+	<xsl:output method="text" />
+
+	<xsl:template match="/">
+			<xsl:value-of select="dummy-root" />
+	</xsl:template>
+
+</xsl:stylesheet>
+EOXSL
+}
+
 sub end : Private {
     my ($self, $c) = @_;
 




More information about the Catalyst-commits mailing list