From: Errietta Kostala Date: Fri, 8 Aug 2014 10:57:17 +0000 (+0100) Subject: Load a *.js for each page X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=35af866e81a1400d4169d5e08b56794fe4b110a6;p=scpubgit%2FApp-SCS.git Load a *.js for each page --- diff --git a/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm b/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm index eaa45d2..d84bc54 100644 --- a/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm +++ b/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm @@ -36,6 +36,13 @@ sub filter_content_zoom { $_[0]->replace(''); } }} + ->select('script[data-cur-page-js]')->${\sub { + if (-f $static_dir . "/page-js/" . $page->path . ".js") { + $_[0]->set_attribute(src => "/static/page-js/" . $page->path . ".js"); + } else { + $_[0]->replace(''); + } + }} } 1;