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

[prev] [thread] [next] [Date index for 2004/09/22]

From: Tosh Cooey
Subject: [Templates] Update to Template/Plugin/XML/Simple.pm
Date: 12:23 on 22 Sep 2004
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/


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] Update to Template/Plugin/XML/Simple.pm
Tosh Cooey 12:23 on 22 Sep 2004

Re: [Templates] Update to Template/Plugin/XML/Simple.pm
Darren Chamberlain 13:03 on 22 Sep 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52