]> git.deb.at Git - deb/packages.git/commitdiff
Add string2id function that is useful in generating HTML id attributes
authorFrank Lichtenheld <frank@lichtenheld.de>
Thu, 23 Nov 2006 21:30:36 +0000 (21:30 +0000)
committerFrank Lichtenheld <frank@lichtenheld.de>
Thu, 23 Nov 2006 21:30:36 +0000 (21:30 +0000)
from random data.

cgi-bin/dispatcher.pl
lib/Packages/CGI.pm

index 45d1b463154539b9c20dc63c71e3b5eb40285650..e34f0e39824b214c0b626d2b278f9fb45931a2c0 100755 (executable)
@@ -269,6 +269,7 @@ $page_content{make_url} = sub { return &Packages::CGI::make_url(@_) };
 $page_content{html_encode} = sub { return HTML::Entities::encode_entities(@_,'<>&"') };
 $page_content{uri_escape} = sub { return URI::Escape::uri_escape(@_) };
 $page_content{quotemeta} = sub { return quotemeta($_[0]) };
+$page_content{string2id} = sub { return &Packages::CGI::string2id(@_) };
 
 print $input->header( -charset => $charset );
 
index 9a8584fe6bd51b4cf784ad1dc37d522215ab4e33..b09235273ab4d9e057321f2a9c494287bdf89e09 100644 (file)
@@ -333,6 +333,13 @@ sub printindexline {
 #    return ( $start, $end );
 #}
 
+sub string2id {
+    my $string = "@_";
+    
+    $string =~ s/[^\w]/_/g;
+    return $string;
+}
+
 our ( %url_params, %query_params );
 
 sub init_url {