]> git.p6c8.net - selfforum.git/blobdiff - selfforum-cgi/shared/Template.pm
just a test
[selfforum.git] / selfforum-cgi / shared / Template.pm
index 44da2cc3d1c831b02ff1e41cf58edfd1dea76619..ece7eaa2f132bf6a0e79f08549c6179c65f32fb9 100644 (file)
@@ -5,6 +5,7 @@ package Template;
 # File:        shared/Template.pm                                              #
 #                                                                              #
 # Authors:     AndrĂ© Malo <nd@o3media.de>, 2001-04-12                          #
 # File:        shared/Template.pm                                              #
 #                                                                              #
 # Authors:     AndrĂ© Malo <nd@o3media.de>, 2001-04-12                          #
+#              Frank Schoenmann <fs@tower.de>, 2001-06-04                      #
 #                                                                              #
 # Description: Handle XML based HTML-Templates                                 #
 #                                                                              #
 #                                                                              #
 # Description: Handle XML based HTML-Templates                                 #
 #                                                                              #
@@ -109,7 +110,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 +121,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 +177,9 @@ sub scrap {
     \%params
   );
 
     \%params
   );
 
+  # remove newlines
+  $scrap =~ s/\n|\r\n|\n\r|\r//g if ($no_nl);
+
   # return
   \$scrap;
 }
   # return
   \$scrap;
 }
@@ -338,4 +350,4 @@ sub parse_if {
 
 #
 #
 
 #
 #
-### end of Template ############################################################
\ No newline at end of file
+### end of Template ############################################################

patrick-canterino.de