[Catalyst-commits] r8641 - in trunk/Catalyst-View-XSLT/lib/Catalyst: Helper/View View View/XSLT/XML

janus at dev.catalyst.perl.org janus at dev.catalyst.perl.org
Sun Nov 23 23:05:56 GMT 2008


Author: janus
Date: 2008-11-23 23:05:56 +0000 (Sun, 23 Nov 2008)
New Revision: 8641

Modified:
   trunk/Catalyst-View-XSLT/lib/Catalyst/Helper/View/XSLT.pm
   trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT.pm
   trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT/XML/LibXSLT.pm
Log:
whitespace cleanup and indentation unification

Modified: trunk/Catalyst-View-XSLT/lib/Catalyst/Helper/View/XSLT.pm
===================================================================
--- trunk/Catalyst-View-XSLT/lib/Catalyst/Helper/View/XSLT.pm	2008-11-23 22:09:07 UTC (rev 8640)
+++ trunk/Catalyst-View-XSLT/lib/Catalyst/Helper/View/XSLT.pm	2008-11-23 23:05:56 UTC (rev 8641)
@@ -74,7 +74,7 @@
 #		],
 #	},
 #);
-																																																		
+
 =head1 NAME
 
 [% class %] - XSLT View Component

Modified: trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT/XML/LibXSLT.pm
===================================================================
--- trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT/XML/LibXSLT.pm	2008-11-23 22:09:07 UTC (rev 8640)
+++ trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT/XML/LibXSLT.pm	2008-11-23 23:05:56 UTC (rev 8641)
@@ -28,45 +28,45 @@
 # {{{ sub new(mixed $proto, oref $c, href $params)
 sub new
 {
-	my ($proto, $c, $params) = @_;
+    my ($proto, $c, $params) = @_;
 
-	eval {
+    eval {
 
-		XML::LibXML->require; 
-		XML::LibXSLT->require;
-	
-		XML::LibXML->import;
-		XML::LibXSLT->import;
-	};
-	
-	if ($@) {
-		$c->error('Could not use XML::LibXSLT: ' . $@);
-		return undef;
-	}
+        XML::LibXML->require; 
+        XML::LibXSLT->require;
 
-	if (exists $params->{register_function}
-		 and ref($params->{register_function}) eq 'ARRAY') {
+        XML::LibXML->import;
+        XML::LibXSLT->import;
+    };
 
-		my $register_subs = $params->{register_function};
+    if ($@) {
+        $c->error('Could not use XML::LibXSLT: ' . $@);
+        return undef;
+    }
 
-		foreach my $hrefSubConf (@{ $register_subs }) {
-			XML::LibXSLT->register_function(
-				$hrefSubConf->{uri},
-				$hrefSubConf->{name},
-				$hrefSubConf->{subref},
-			);
-		}
-		 
-	 }
-	
-	my $class = ref $proto || $proto;
-	
-	my $self = {};
-	
-	bless($self, $class);
-	
-	return $self;
-	
+    if (exists $params->{register_function}
+      and ref($params->{register_function}) eq 'ARRAY') {
+
+        my $register_subs = $params->{register_function};
+
+        foreach my $hrefSubConf (@{ $register_subs }) {
+            XML::LibXSLT->register_function(
+              $hrefSubConf->{uri},
+              $hrefSubConf->{name},
+              $hrefSubConf->{subref},
+            );
+         }
+
+    }
+
+    my $class = ref $proto || $proto;
+
+    my $self = {};
+
+    bless($self, $class);
+
+    return $self;
+
 }
 # }}}
 
@@ -75,45 +75,43 @@
 =cut
 
 sub process {
+    my ($self, $template, $args) = @_;
 
-	my ($self, $template, $args) = @_;
+    my ($result, $error) = ('', undef);
 
-	my ($result, $error) = ('', undef);
+    eval {	
+        my $xmlParser = XML::LibXML->new();
+        my $xsltProcessor = XML::LibXSLT->new();
 
-	eval {	
-		my $xmlParser = XML::LibXML->new();
+        my ($xmlDocument, $xsltStylesheet);
 
-		my $xsltProcessor = XML::LibXSLT->new();
+        my $xml = delete $args->{xml};
 
-		my 	($xmlDocument, $xsltStylesheet);
-	    
-	    my $xml = delete $args->{xml};
+        if ($xml =~ /\</) {
+            $xmlDocument = $xmlParser->parse_string($xml);
+        } else {
+            $xmlDocument = $xmlParser->parse_file($xml);
+        }
 
-	    if ($xml =~ /\</) {
-			$xmlDocument = $xmlParser->parse_string($xml);
-	    } else {
-			$xmlDocument = $xmlParser->parse_file($xml);
-	    }
-	
-		if ($template =~ m/\</) {
-			$xsltStylesheet = $xmlParser->parse_string($template);
-		} else {
-			$xsltStylesheet = $xmlParser->parse_file($template);
-		}
+        if ($template =~ m/\</) {
+            $xsltStylesheet = $xmlParser->parse_string($template);
+        } else {
+            $xsltStylesheet = $xmlParser->parse_file($template);
+        }
 
-		my $xsltTransformer = $xsltProcessor->parse_stylesheet($xsltStylesheet);
+        my $xsltTransformer = $xsltProcessor->parse_stylesheet($xsltStylesheet);
 
-		my %params = XML::LibXSLT::xpath_to_string( %{$args} );
+        my %params = XML::LibXSLT::xpath_to_string( %{$args} );
 
-		my $results = $xsltTransformer->transform($xmlDocument, %params);
+        my $results = $xsltTransformer->transform($xmlDocument, %params);
 
-		$result = $xsltTransformer->output_string($results);
-		
-	};
+        $result = $xsltTransformer->output_string($results);
 
-	$error = $@;
+    };
 
-	return ($result, $error);
+    $error = $@;
+
+    return ($result, $error);
 }
 
 =back

Modified: trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT.pm
===================================================================
--- trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT.pm	2008-11-23 22:09:07 UTC (rev 8640)
+++ trunk/Catalyst-View-XSLT/lib/Catalyst/View/XSLT.pm	2008-11-23 23:05:56 UTC (rev 8641)
@@ -31,15 +31,15 @@
 	    MyApp->path_to( 'root', 'xslt' ),
 		MyApp->path_to( 'templates', 'xsl' ),
 	  ],
-	    
+
 	  # default template extension to use
 	  # when you don't provide template name
 	  TEMPLATE_EXTENSION => '.xsl',
-		
+
 	  # use this for debug purposes
 	  # it will dump the the final (merged) config
 	  DUMP_CONFIG => 1,
-	
+
 	  # XML::LibXSLT specific configuration 
 	  LibXSLT => {
 	    register_function => [
@@ -63,10 +63,10 @@
 
     # In your controller(s) :
     sub someAction : Local {
-		
+
       # 'template' could be string or path to file
       # see 'xml' for more info about string version 
-	  
+
       # path to the template could be absolute
       $c->stash->{template} = $c->config->{home} . 'root/some.xsl';
 
@@ -75,7 +75,7 @@
 
       # or if you didn't provide any template name 
       # then the last chance is 'someAction.xsl' ($c->action . $config->{TEMPLATE_EXTENSION})
-		
+
       # 'xml' could be string
       $c->stash->{xml} =<<XML;
 <root>
@@ -96,16 +96,16 @@
           subref => sub { return $obj->method(@_) },
         }
       ];
-		
+
       # everything else in the stash will be used for parameters (<xsl:param name="param1" />)
       $c->stash->{param1} = 'Param1 value';'
       $c->stash->{param2} = 'Param2 value';
     }
 
     # Meanwhile, maybe in an 'end' action
-        
+
     $c->forward('MyApp::View::XSLT');
-    
+
     # to use your registered functions in some.xsl:
     <xsl:stylesheet 
 	  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
@@ -151,38 +151,37 @@
 
 # new (mixed $proto, oref $c, href $params)
 sub new {
+    my ($proto, $c) = @_;
 
-	my ($proto, $c) = @_;
+    my $class = ref $proto || $proto;
 
-	my $class = ref $proto || $proto;
+    # default configuration
+    my $config = {
+        # DEFAULT VALUES
 
-	# default configuration
-	my $config = {
-		# DEFAULT VALUES
-		
-		# this the default internal implementation
-		# can be overwritten in application or class config
-		PROCESSOR => 'Catalyst::View::XSLT::XML::LibXSLT',
+        # this the default internal implementation
+        # can be overwritten in application or class config
+        PROCESSOR => 'Catalyst::View::XSLT::XML::LibXSLT',
 
-		# default file extension for xslt files
-		TEMPLATE_EXTENSION => '.xsl',
+        # default file extension for xslt files
+        TEMPLATE_EXTENSION => '.xsl',
 
-		# don't dump XSLT view config by default
-		DUMP_CONFIG => 0,
-	
-		# DEFAULT VALUES END
-		
-		
-		# global app config
-		%{ $c->config->{'View::XSLT'} || {} },
-		%{ $c->config->{'V::XSLT'} || {} },
-		
-		# class' config has precedence
-		%{ $class->config() || {} },
-	};
-	
+        # don't dump XSLT view config by default
+        DUMP_CONFIG => 0,
 
-	if ( ! (ref $config->{INCLUDE_PATH} eq 'ARRAY') ) {
+        # DEFAULT VALUES END
+
+
+        # global app config
+        %{ $c->config->{'View::XSLT'} || {} },
+        %{ $c->config->{'V::XSLT'} || {} },
+
+        # class' config has precedence
+        %{ $class->config() || {} },
+    };
+
+
+    if ( ! (ref $config->{INCLUDE_PATH} eq 'ARRAY') ) {
         my $delim = $config->{DELIMITER};
         my @include_path
             = _coerce_paths( $config->{INCLUDE_PATH}, $delim );
@@ -194,17 +193,17 @@
         $config->{INCLUDE_PATH} = \@include_path;
     }
 
-	if ( $c->debug && $config->{DUMP_CONFIG} ) {
+    if ( $c->debug && $config->{DUMP_CONFIG} ) {
         $c->log->debug( 'XSLT Config: ', Dumper($config) );
     }
 
-	my $self = {};
+    my $self = {};
 
-	bless($self, $class);
+    bless($self, $class);
 
-	$self->{CONFIG} = $config;
+    $self->{CONFIG} = $config;
 
-	return $self;
+    return $self;
 }
 # 
 
@@ -221,7 +220,7 @@
 
     unless ( -e $template) {
         my ($tmplFullPath, $error) = $self->_searchInIncPath($c, $template);
-		
+
         if (defined $error) {
             $c->error("Template [$template] does not exists in include path");
             return 0;
@@ -245,7 +244,7 @@
     # and is not existsting in the file system
     if ($xml !~ m/\</ && ! -e $xml) {
         my ($xmlFullPath, $error) = $self->_searchInIncPath($c, $xml);
-		
+
         if (defined $error) {
             $c->error("Template [$template] does not exists in include path");
             return undef;
@@ -311,17 +310,17 @@
     my ( $self, $c ) = @_;
 
     my $template = undef;
-    
+
     if (exists $c->stash->{template} && defined $c->stash->{template}) {
     	$template = delete $c->stash->{template};
     } else {
     	my $actionName = $c->action;
     	my $ext = $self->{CONFIG}->{'TEMPLATE_EXTENSION'};
-    	
-		$template = $actionName . $ext;
+
+        $template = $actionName . $ext;
     	$c->log->debug( "Going to create template name from the action name and default extension: [$template]" ) if $c->debug;
     }
-    
+
     unless ($template) {
     	# probably this will never happen, but for any case
         $c->log->error( 'No template specified for rendering' );
@@ -339,44 +338,43 @@
 
 # returns the current set internal processor
 sub _getProcessor {
-	
-	my ($self) = @_;
-	
-	return $self->{CONFIG}->{PROCESSOR};
+    my ($self) = @_;
+
+    return $self->{CONFIG}->{PROCESSOR};
 }
 
 # searchs for a file ($filename) in INCLUDE_PATH
 # returns the first occurence
 sub _searchInIncPath {
-	my ($self, $c, $filename) = @_;
-	
-	$c->log->debug( "searching in include path for [$filename]") if $c->debug;
-        
-	my $arefIncludePath = $self->{CONFIG}->{'INCLUDE_PATH'};
-        
-	unshift( @{ $arefIncludePath }, @{ $c->stash->{additional_template_paths} } )
-		if (ref $c->stash->{additional_template_paths} eq 'ARRAY');
-	
-	foreach my $incEntry ( @{ $arefIncludePath} ) {
+    my ($self, $c, $filename) = @_;
 
-		$c->log->debug( "Going to search for file [$filename] in [$incEntry]" ) if $c->debug;			
-		my $tmpTemplateName = '';
-		
-		if (ref $incEntry eq 'Path::Class::File') {
-			$tmpTemplateName = File::Spec->catfile($incEntry->absolute, $filename);
-		} else {
-			$tmpTemplateName = File::Spec->catfile($incEntry, $filename);
-		}
-			
-		if (-e $tmpTemplateName) {
-		
-			$c->log->debug( "File [$filename] found in [$incEntry]") if $c->debug;
-			return ($tmpTemplateName, undef);
-		}
-		
-	}
+    $c->log->debug( "searching in include path for [$filename]") if $c->debug;
 
-	return (undef, 1);	
+    my $arefIncludePath = $self->{CONFIG}->{'INCLUDE_PATH'};
+
+    unshift( @{ $arefIncludePath }, @{ $c->stash->{additional_template_paths} } )
+      if (ref $c->stash->{additional_template_paths} eq 'ARRAY');
+
+    foreach my $incEntry ( @{ $arefIncludePath} ) {
+
+        $c->log->debug( "Going to search for file [$filename] in [$incEntry]" ) if $c->debug;
+        my $tmpTemplateName = '';
+
+        if (ref $incEntry eq 'Path::Class::File') {
+            $tmpTemplateName = File::Spec->catfile($incEntry->absolute, $filename);
+        } else {
+            $tmpTemplateName = File::Spec->catfile($incEntry, $filename);
+        }
+
+        if (-e $tmpTemplateName) {
+
+            $c->log->debug( "File [$filename] found in [$incEntry]") if $c->debug;
+            return ($tmpTemplateName, undef);
+        }
+
+    }
+
+    return (undef, 1);	
 }
 
 =back
@@ -398,7 +396,6 @@
 This program is free software, you can redistribute it and/or modify it
 under the same terms as Perl itself.
 
-
 =cut
 
 1;




More information about the Catalyst-commits mailing list