summaryrefslogtreecommitdiff
path: root/themes/CodeIT/layouts/partials/plugin/script.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/CodeIT/layouts/partials/plugin/script.html')
-rw-r--r--themes/CodeIT/layouts/partials/plugin/script.html25
1 files changed, 25 insertions, 0 deletions
diff --git a/themes/CodeIT/layouts/partials/plugin/script.html b/themes/CodeIT/layouts/partials/plugin/script.html
new file mode 100644
index 0000000..e12e74e
--- /dev/null
+++ b/themes/CodeIT/layouts/partials/plugin/script.html
@@ -0,0 +1,25 @@
+{{- if .Content -}}
+ <script type="text/javascript">
+ {{- .Content | safeJS -}}
+ </script>
+{{- else if strings.HasPrefix .Source "<script" -}}
+ {{- safeHTML .Source -}}
+{{- else -}}
+ {{- $src := .Source -}}
+ {{- $integrity := .Integrity -}}
+ {{- if (urls.Parse $src).Host | not -}}
+ {{- $resource := resources.Get $src -}}
+ {{- with .Template -}}
+ {{- $resource = $resource | resources.ExecuteAsTemplate . $.Context -}}
+ {{- end -}}
+ {{- if .Minify -}}
+ {{- $resource = $resource | minify -}}
+ {{- end -}}
+ {{- with .Fingerprint -}}
+ {{- $resource = $resource | fingerprint . -}}
+ {{- $integrity = $resource.Data.Integrity -}}
+ {{- end -}}
+ {{- $src = $resource.RelPermalink -}}
+ {{- end -}}
+ <script type="text/javascript" src="{{ $src }}"{{ if .Crossorigin }} crossorigin="anonymous"{{ end }}{{ with $integrity }} integrity="{{ . }}"{{ end }}{{ if .Async }} async{{ end }}{{ if .Defer }} defer{{ end }}{{ with .Attr }} {{ . | safeHTMLAttr }}{{ end }}></script>
+{{- end -}}