Files
Bjørn Erik Pedersen b51bdc88cc Make it compatible with Hugo 0.55 (#13680)
This commit adds two backwards compatible changes to prepare for the next Hugo version, most notable:

* All the `File` methods on `Page` has been deprecated and will give a warning in the next Hugo version. Adjust this by changing `.Dir` to ´.File.Dir` and similar.
* Version the capture shortcode to use the old behaviour for markdown rendering of shortcode inner content.
2019-04-08 18:19:05 -07:00

28 lines
968 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.File.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 'includes' bundle was not found." $.Page.Lang }}
{{- end -}}
{{- else -}}
{{- errorf "[%s] missing resource name in include for page %q" $.Page.Lang $.Page.Path -}}
{{- end -}}