Răsfoiți Sursa

inject custom script to layout file

Yuki Takei 8 ani în urmă
părinte
comite
729ad606f5
3 a modificat fișierele cu 14 adăugiri și 0 ștergeri
  1. 5 0
      lib/util/swigFunctions.js
  2. 3 0
      lib/views/layout/admin.html
  3. 6 0
      lib/views/layout/layout.html

+ 5 - 0
lib/util/swigFunctions.js

@@ -55,6 +55,11 @@ module.exports = function(crowi, app, req, locals) {
     return Config.customCss();
   }
 
+  locals.customScript = function() {
+    console.log(Config.customScript());
+    return Config.customScript();
+  }
+
   locals.behaviorType = function() {
     var config = crowi.getConfig()
     return Config.behaviorType(config);

+ 3 - 0
lib/views/layout/admin.html

@@ -5,3 +5,6 @@
   <script src="{{ webpack_asset('legacy-admin').js }}" defer></script>
 {% endblock %}
 
+{# disable custom script in admin page #}
+{% block custom_script %}
+{% endblock %}

+ 6 - 0
lib/views/layout/layout.html

@@ -182,4 +182,10 @@
 {{ local_config|json|safe }}
 </script>
 
+{% block custom_script %}
+<script>
+  {{ customScript() }}
+</script>
+{% endblock %}
+
 </html>