[Templates-cvs] cvs commit: Template2/lib/Template/Plugin/XML Simple.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
Fri, 24 Sep 2004 07:49:13 +0100
cvs 04/09/24 06:49:13
Modified: lib/Template/Plugin/XML Simple.pm
Log:
* added patch from Tosh Cooey to fix new() to return a XML::Simple object
if no input parameter is provided.
Revision Changes Path
2.65 +14 -3 Template2/lib/Template/Plugin/XML/Simple.pm
Index: Simple.pm
===================================================================
RCS file: /template-toolkit/Template2/lib/Template/Plugin/XML/Simple.pm,v
retrieving revision 2.64
retrieving revision 2.65
diff -u -r2.64 -r2.65
--- Simple.pm 2004/01/30 19:33:36 2.64
+++ Simple.pm 2004/09/24 06:49:13 2.65
@@ -16,7 +16,7 @@
#
#----------------------------------------------------------------------------
#
-# $Id: Simple.pm,v 2.64 2004/01/30 19:33:36 abw Exp $
+# $Id: Simple.pm,v 2.65 2004/09/24 06:49:13 abw Exp $
#
#============================================================================
@@ -31,7 +31,7 @@
use base qw( Template::Plugin );
use vars qw( $VERSION );
-$VERSION = sprintf("%d.%02d", q$Revision: 2.64 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 2.65 $ =~ /(\d+)\.(\d+)/);
#------------------------------------------------------------------------
@@ -44,7 +44,18 @@
my $input = shift;
my $args = ref $_[-1] eq 'HASH' ? pop(@_) : { };
- XMLin($input, %$args);
+ if (defined($input)) {
+ # an input parameter can been be provided and can contain
+ # XML text or the filename of an XML file, which we load
+ # using insert() to honour the INCLUDE_PATH; then we feed
+ # it into XMLin().
+ $input = $context->insert($input) unless ( $input =~ /</ );
+ return XMLin($input, %$args);
+ }
+ else {
+ # otherwise return a XML::Simple object
+ return new XML::Simple;
+ }
}