LoveIt/layouts/partials/plugin/script.html
Dillon 90184ca3e7
feat(search): add local search (#231)
* feat(search): add local search

* docs: add docs for search
2020-04-15 15:46:50 +08:00

21 lines
959 B
HTML

{{- 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 -}}