LoveIt/layouts/partials/plugin/script.html

22 lines
959 B
HTML
Raw Normal View History

{{- if strings.HasPrefix .source "<script" -}}
{{- safeHTML .source -}}
{{- else -}}
{{- $src := .source -}}
{{- $integrity := .integrity -}}
{{- if strings.HasPrefix $src "http" | 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 -}}