Load a *.js for each page
Errietta Kostala [Fri, 8 Aug 2014 10:57:17 +0000 (11:57 +0100)]
lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm

index eaa45d2..d84bc54 100644 (file)
@@ -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;