aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Page.pm
diff options
context:
space:
mode:
authormatthew <matthew>2009-10-29 11:31:58 +0000
committermatthew <matthew>2009-10-29 11:31:58 +0000
commitd106fc654fd39b9d5e342c996b8b7cec6e7bea0a (patch)
tree8827a607e84241785c3fada3a486c651f87b80e0 /perllib/Page.pm
parent8a9d62709ca3c724ddc3cbbd9feb8a6a66bb7eca (diff)
Default for rss parameter, factor out substitution in new function.
Diffstat (limited to 'perllib/Page.pm')
-rw-r--r--perllib/Page.pm18
1 files changed, 15 insertions, 3 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 0adc38451..ff7a8ba23 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.pm,v 1.194 2009-10-29 11:16:02 matthew Exp $
+# $Id: Page.pm,v 1.195 2009-10-29 11:31:58 matthew Exp $
#
package Page;
@@ -198,6 +198,7 @@ sub template_vars ($%) {
'lang' => $params{lang} eq 'en-gb' ? 'Cymraeg' : 'English',
'lang_url' => $lang_url,
'title' => $params{title},
+ 'rss' => '',
);
if ($params{rss}) {
@@ -230,6 +231,18 @@ sub template($%){
return $template;
}
+=item template_substitute TEMPLATE VARS
+
+Substitutes the VARS into TEMPLATE.
+
+=cut
+
+sub template_substitute($%) {
+ my ($template, %vars) = @_;
+ $template =~ s#{{ ([a-z_]+) }}#$vars{$1}#g;
+ return $template;
+}
+
=item template_header TEMPLATE Q ROOT PARAMS
Return HTML for the templated top of a page, given a
@@ -247,8 +260,7 @@ sub template_header($$$%) {
my $html = join('', <FP>);
close FP;
my $vars = template_vars($q, %params);
- $html =~ s#{{ ([a-z_]+) }}#$vars->{$1}#g;
- return $html;
+ return template_substitute($html, %$vars);
}
=item header Q [PARAM VALUE ...]