mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-14 10:09:31 -07:00
42 lines
1.3 KiB
HTML
42 lines
1.3 KiB
HTML
{{- if .Content -}}
|
|
<script type="text/javascript">
|
|
{{- .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 -}}
|
|
{{- with .ToESBuild -}}
|
|
{{- $resource = $resource | js.Build . -}}
|
|
{{- end -}}
|
|
{{- if .Minify -}}
|
|
{{- $resource = $resource | minify -}}
|
|
{{- end -}}
|
|
{{- with .Fingerprint -}}
|
|
{{- $resource = $resource | fingerprint . -}}
|
|
{{- $integrity = $resource.Data.Integrity -}}
|
|
{{- end -}}
|
|
{{- $src = $resource.RelPermalink -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- with .Link -}}
|
|
{{- $src = . -}}
|
|
{{- 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 -}}
|