Files
website/layouts/shortcodes/include.html
T
Luc Perkins c6dd35ba51 Update to Hugo 0.53 and remove all .Site references (#12079)
* Remove all .Site variable references

* Update Hugo version in Travis CI config and Makefile
2019-02-05 08:33:23 -08:00

28 lines
964 B
HTML

{{/* This will try to find a resource in the "includes" bundle */}}
{{- $name := .Get 0 -}}
{{- if $name -}}
{{- $bundle := site.GetPage "page" "includes" -}}
{{- with $bundle -}}
{{- $pattern := printf "%s*" $name -}}
{{- range $bundle.Resources -}}
{{- end -}}
{{- $resource := $bundle.Resources.GetMatch $pattern -}}
{{- with $resource -}}
{{- .Content | safeHTML -}}
{{- else -}}
{{/* It is not a resource in the includes bundle. Try to find the page relative to the current. */}}
{{- $path := path.Join $.Page.Dir $name -}}
{{- $page := site.GetPage "page" $path -}}
{{- with $page }}
{{ .Content }}
{{- else -}}
{{ errorf "[%s] no Resource or Page matching %q." $.Page.Lang ($pattern | safeHTML ) }}
{{- end -}}
{{- end -}}
{{- else -}}
{{ errorf "[%s] the 'inclucdes' bundle was not found." $.Page.Lang }}
{{- end -}}
{{- else -}}
{{- errorf "[%s] missing resource name in include for page %q" $.Page.Lang $.Page.Path -}}
{{- end -}}