2018-05-05 16:00:51 +00:00
{{- $id := .Get "term_id" -}}
{{- $length := .Get "length" -}}
{{- $prepend := .Get "prepend" }}
2019-02-05 16:33:23 +00:00
{{- $glossaryBundle := site.GetPage "page" "docs/reference/glossary" -}}
2018-05-05 16:00:51 +00:00
{{- $glossaryItems := $glossaryBundle.Resources.ByType "page" -}}
{{- $term_info := $glossaryItems.GetMatch (printf "%s*" $id ) -}}
{{- if not $term_info -}}
2019-02-05 16:33:23 +00:00
{{- errorf "[%s] %q: %q is not a valid glossary term_id, see ./docs/reference/glossary/* for a full list" site.Language.Lang .Page.Path $id -}}
2018-05-05 16:00:51 +00:00
{{- end -}}
{{- with $term_info -}}
{{- if (strings.Contains "short" $length) -}}
{{- with .Summary -}}
{{- if $prepend }}{{- replace . "< p > " (printf "< P > %s %s" $prepend .) -}}{{ else }}{{- . -}}{{ end -}}
{{- else -}}
2019-03-09 08:33:29 +00:00
{{- partial "templates/errorthrower.html" (dict "block" "summary" "purpose" .purpose "describes the key term in greater depth, supplementing the short_description") . -}}
2018-05-05 16:00:51 +00:00
{{- end -}}
{{- end -}}
{{- if (strings.Contains "all|long" $length) -}}
{{- with .Content -}}
{{- if $prepend }}
{{- $firstPara := index (findRE "(?s)< p > .*?< / p > " . 1) 0 -}}
{{- $firstPara := $firstPara | strings.TrimSuffix "< / p > " | strings.TrimPrefix "< p > " -}}
{{- $first := slicestr $firstPara 0 1 | lower }}
{{- $prepended := printf "< p > %s %s%s< / p > " $prepend $first (slicestr $firstPara 1) -}}
{{- replace . $firstPara $prepended | safeHTML -}}{{ else }}{{- . -}}{{ end -}}
{{- end -}}
{{- end -}}
2019-02-05 16:33:23 +00:00
{{- end -}}