LoveIt/layouts/partials/plugin/script.html

21 lines
994 B
HTML

{{- if strings.HasPrefix .source "<script" -}}
{{- safeHTML .source -}}
{{- else -}}
{{- $src := .source -}}
{{- $integrity := .integrity -}}
{{- if strings.HasPrefix $src "http" | or (strings.HasPrefix $src "//") | not -}}
{{- $res := resources.Get $src -}}
{{- with .template -}}
{{- $res = $res | resources.ExecuteAsTemplate . $.context -}}
{{- end -}}
{{- if .minify -}}
{{- $res = $res | minify -}}
{{- end -}}
{{- with .fingerprint -}}
{{- $res = $res | fingerprint . -}}
{{- $integrity = $res.Data.Integrity -}}
{{- end -}}
{{- $src = $res.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 -}}