2020-04-15 09:46:50 +02:00
|
|
|
{{- if strings.HasPrefix .source "<script" -}}
|
|
|
|
{{- safeHTML .source -}}
|
2020-03-09 13:25:55 +01:00
|
|
|
{{- else -}}
|
2020-04-15 09:46:50 +02:00
|
|
|
{{- $src := .source -}}
|
|
|
|
{{- $integrity := .integrity -}}
|
2020-04-22 17:58:40 +02:00
|
|
|
{{- if (urls.Parse $src).Host | not -}}
|
2020-04-15 09:46:50 +02:00
|
|
|
{{- $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>
|
2020-03-09 13:25:55 +01:00
|
|
|
{{- end -}}
|