mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
2efcf947a7
The default `type` for `<script>` tags is `JavaScript`, so you don’t need to include the type for JS resources.
26 lines
1.0 KiB
HTML
26 lines
1.0 KiB
HTML
{{- if .Content -}}
|
|
<script>{{- .Content | safeJS -}}</script>
|
|
{{- else if strings.HasPrefix .Source "<script" -}}
|
|
{{- safeHTML .Source -}}
|
|
{{- else -}}
|
|
{{- $src := .Source -}}
|
|
{{- $integrity := .Integrity -}}
|
|
{{- if $src -}}
|
|
{{- 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 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 -}}
|
|
{{- end -}}
|