diff options
author | Dave Arter <davea@mysociety.org> | 2017-07-20 11:00:42 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2017-08-02 17:29:12 +0100 |
commit | 0efa708beb3fcd14413d4ec6d84fbdea76904881 (patch) | |
tree | 41fee314be6a1ced915e6ace0be1a6db7a614279 | |
parent | f3994a336c33b585e116674baeb19fd918eb3ab0 (diff) |
Cache template paths in About.pm with lang_code
Fixes #1765
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/About.pm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/About.pm b/perllib/FixMyStreet/App/Controller/About.pm index 78e548c5f..233da25d3 100755 --- a/perllib/FixMyStreet/App/Controller/About.pm +++ b/perllib/FixMyStreet/App/Controller/About.pm @@ -34,22 +34,24 @@ sub index : Path("/about") : Args(0) { sub find_template : Private { my ( $self, $c, $page ) = @_; - return $found{$page} if !FixMyStreet->config('STAGING_SITE') && exists $found{$page}; - my $lang_code = $c->stash->{lang_code}; + + return $found{$lang_code}{$page} if !FixMyStreet->config('STAGING_SITE') && + exists $found{$lang_code}{$page}; + foreach my $dir_templates (@{$c->stash->{additional_template_paths}}, @{$c->view('Web')->paths}) { foreach my $dir_static (static_dirs($page, $dir_templates)) { foreach my $file ("$page-$lang_code.html", "$page.html") { if (-e "$dir_templates/$dir_static/$file") { - $found{$page} = "$dir_static/$file"; - return $found{$page}; + $found{$lang_code}{$page} = "$dir_static/$file"; + return $found{$lang_code}{$page}; } } } } # Cache that the page does not exist, so we don't look next time - $found{$page} = undef; - return $found{$page}; + $found{$lang_code}{$page} = undef; + return $found{$lang_code}{$page}; } sub static_dirs { |