]> git.p6c8.net - selfforum.git/blobdiff - selfforum-cgi/shared/Template.pm
added error message for xml-parse-error.
[selfforum.git] / selfforum-cgi / shared / Template.pm
index 44da2cc3d1c831b02ff1e41cf58edfd1dea76619..4e19eb24d3f21e73bafa8aecb81e573c1d24eabc 100644 (file)
@@ -4,16 +4,23 @@ package Template;
 #                                                                              #
 # File:        shared/Template.pm                                              #
 #                                                                              #
 #                                                                              #
 # File:        shared/Template.pm                                              #
 #                                                                              #
-# Authors:     AndrĂ© Malo <nd@o3media.de>, 2001-04-12                          #
+# Authors:     AndrĂ© Malo       <nd@o3media.de>, 2001-06-16                    #
+#              Frank Schoenmann <fs@tower.de>,   2001-06-04                    #
 #                                                                              #
 # Description: Handle XML based HTML-Templates                                 #
 #                                                                              #
 ################################################################################
 
 use strict;
 #                                                                              #
 # Description: Handle XML based HTML-Templates                                 #
 #                                                                              #
 ################################################################################
 
 use strict;
-use vars qw($xml_dom_used);
+use vars qw(
+  $xml_dom_used
+  $VERSION
+);
 
 
-use Carp qw(croak confess);
+use Carp qw(
+  croak
+  confess
+);
 
 BEGIN {
   $xml_dom_used = eval q[
 
 BEGIN {
   $xml_dom_used = eval q[
@@ -23,6 +30,13 @@ BEGIN {
   ];
 }
 
   ];
 }
 
+################################################################################
+#
+# Version check
+#
+$VERSION = do { my @r =(q$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+
+
 ### sub new ####################################################################
 #
 # constructor
 ### sub new ####################################################################
 #
 # constructor
@@ -109,7 +123,10 @@ sub list {
 #
 # fill in a template scrap
 #
 #
 # fill in a template scrap
 #
-# Params: $name - name of the scrap
+# Params: $name    name of the scrap
+#         ...
+#         $no_nl   1 - remove newlines (\n)
+#                  0 - do no such thing
 #
 # Return: scalar reference - filled in scrap
 #
 #
 # Return: scalar reference - filled in scrap
 #
@@ -117,6 +134,11 @@ sub scrap {
   my $self = shift;
   my $name = shift;
 
   my $self = shift;
   my $name = shift;
 
+  my $no_nl;
+  if (!ref $_[$#_]) {
+      $no_nl = pop @_;
+  }
+
   croak "no template file specified"
     unless (defined $self -> {file});
 
   croak "no template file specified"
     unless (defined $self -> {file});
 
@@ -168,6 +190,10 @@ sub scrap {
     \%params
   );
 
     \%params
   );
 
+  # remove newlines
+  #
+  $scrap =~ s/\015\012|\015|\012//g if ($no_nl);
+
   # return
   \$scrap;
 }
   # return
   \$scrap;
 }
@@ -333,7 +359,7 @@ sub parse_if {
   return;
 }
 
   return;
 }
 
-# keeping 'require' happy
+# keep 'require' happy
 1;
 
 #
 1;
 
 #

patrick-canterino.de