]> git.p6c8.net - selfforum.git/blobdiff - selfforum-cgi/shared/Template.pm
sort threads by number, not alphabetically
[selfforum.git] / selfforum-cgi / shared / Template.pm
index 44da2cc3d1c831b02ff1e41cf58edfd1dea76619..0400ec748a4f7b7e2a67cdc430e75b7997768be9 100644 (file)
@@ -4,16 +4,19 @@ package Template;
 #                                                                              #
 # File:        shared/Template.pm                                              #
 #                                                                              #
-# Authors:     André Malo <nd@o3media.de>, 2001-04-12                          #
+# Authors:     André Malo <nd@o3media.de>                                      #
+#              Frank Schönmann <fs@tower.de>                                   #
 #                                                                              #
 # Description: Handle XML based HTML-Templates                                 #
 #                                                                              #
 ################################################################################
 
 use strict;
-use vars qw($xml_dom_used);
+use vars qw(
+  $xml_dom_used
+);
 
-use Carp qw(croak confess);
+use Carp qw(croak);
 
 BEGIN {
   $xml_dom_used = eval q[
@@ -23,6 +26,17 @@ BEGIN {
   ];
 }
 
+################################################################################
+#
+# Version check
+#
+# last modified:
+#    $Date$ (GMT)
+# by $Author$
+#
+sub VERSION {(q$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
+
+
 ### sub new ####################################################################
 #
 # constructor
@@ -109,7 +123,10 @@ sub list {
 #
 # 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
 #
@@ -117,6 +134,11 @@ sub scrap {
   my $self = shift;
   my $name = shift;
 
+  my $no_nl;
+  if (!ref $_[$#_]) {
+      $no_nl = pop @_;
+  }
+
   croak "no template file specified"
     unless (defined $self -> {file});
 
@@ -168,6 +190,10 @@ sub scrap {
     \%params
   );
 
+  # remove newlines
+  #
+  $scrap =~ s/\015\012|\015|\012//g if ($no_nl);
+
   # return
   \$scrap;
 }
@@ -333,7 +359,7 @@ sub parse_if {
   return;
 }
 
-# keeping 'require' happy
+# keep 'require' happy
 1;
 
 #

patrick-canterino.de