[Templates] Update to Template/Plugin/XML/Simple.pm

Tosh Cooey tosh@1200group.com
Wed, 22 Sep 2004 14:23:27 +0200


Hi Andy, would it be possible to add this update to the XML::Simple plugin?

OLD 'new'
sub new {
     my $class   = shift;
     my $context = shift;
     my $input   = shift;
     my $args    = ref $_[-1] eq 'HASH' ? pop(@_) : { };

     XMLin($input, %$args);
}


NEW 'new'
sub new {
     my $class   = shift;
     my $context = shift;
     my $input   = shift;
     my $args    = ref $_[-1] eq 'HASH' ? pop(@_) : { };

     if (defined($input)) {  # Don't want to break anything...
         return XMLin($input, %$args);
     } else {
         return new XML::Simple;
     }
}


And a small change to the docs...
=head1 SYNOPSIS

     # load plugin and specify XML file to parse
     [% USE xml = XML.Simple(xml_file_or_text) %]

     # Or load plugin as an object
     [% USE xml = XML.Simple %]
     # Then use XMLin or XMLout as usual
     [% xml.XMLout(data_ref, args) %]
     [% xml.XMLin(xml_file_or_text, args) %]


Thanks!!

Tosh

-- 
McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/