Przeglądaj źródła

inject custom script to layout file

Yuki Takei 9 lat temu
rodzic
commit
729ad606f5

+ 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>