From: Frank Lichtenheld Date: Fri, 14 Sep 2007 20:35:16 +0000 (+0200) Subject: create_index_pages: Make common functions available to all templates X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=e251bfc88a72b4836e8dea25baeb87990310d653;p=deb%2Fpackages.git create_index_pages: Make common functions available to all templates The common functions were only available in suite_index.tmpl, but not in index.tmpl. Fix that by giving them to the initial Packages::Template->new call. --- diff --git a/bin/create_index_pages b/bin/create_index_pages index 30962ea..8586671 100755 --- a/bin/create_index_pages +++ b/bin/create_index_pages @@ -49,9 +49,16 @@ my $priorities = retrieve "$DBDIR/priorities.info"; #use Data::Dumper; #print STDERR Dumper($sections, $subsections, $priorities); -my (%pages); +my (%pages, %tt_vars); -my $template = new Packages::Template( "$TOPDIR/templates", 'html', {} ); +$tt_vars{make_search_url} = sub { return &Packages::CGI::make_search_url(@_) }; +$tt_vars{make_url} = sub { return &Packages::CGI::make_url(@_) }; +# needed to work around the limitations of the the FILTER syntax +$tt_vars{html_encode} = sub { return HTML::Entities::encode_entities(@_,'<>&"') }; +$tt_vars{uri_escape} = sub { return URI::Escape::uri_escape(@_) }; +$tt_vars{quotemeta} = sub { return quotemeta($_[0]) }; + +my $template = new Packages::Template( "$TOPDIR/templates", 'html', \%tt_vars ); print "write suite index files ...\n"; foreach my $s (@SUITES) { @@ -70,13 +77,6 @@ foreach my $s (@SUITES) { my %content = ( subsections => [], suite => $s, lang => $lang, charset => $charset, used_langs => \@LANGUAGES, suites => \@SUITES ); - $content{make_search_url} = sub { return &Packages::CGI::make_search_url(@_) }; - $content{make_url} = sub { return &Packages::CGI::make_url(@_) }; - # needed to work around the limitations of the the FILTER syntax - $content{html_encode} = sub { return HTML::Entities::encode_entities(@_,'<>&"') }; - $content{uri_escape} = sub { return URI::Escape::uri_escape(@_) }; - $content{quotemeta} = sub { return quotemeta($_[0]) }; - foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) { next if $ssec eq '-'; if ($sections_descs{$ssec}) {