Debian Codegraph @

docs/layouts/_shortcodes/eturl.html

raw
1 {{/*
2 Renders an absolute URL to the source code for an embedded template.
3
4 Accepts either positional or named parameters, and depends on the
5 embedded_templates.toml file in the data directory.
6
7 @param {string} filename The embedded template's file name, excluding extension.
8
9 @example {{% et robots.txt %}}
10 @example {{% et filename=robots.txt %}}
11 */}}
12
13 {{- with $filename := or (.Get "filename") (.Get 0) }}
14 {{- with hugo.Data.embedded_template_urls }}
15 {{- with index . $filename }}
16 {{- urls.JoinPath hugo.Data.embedded_template_urls.base_url . }}
17 {{- else }}
18 {{- errorf "The %q shortcode was unable to find a URL for the embedded template named %q. Check the name. See %s" $.Name $filename $.Position }}
19 {{- end }}
20 {{- else }}
21 {{- errorf "The %q shortcode was unable to find the embedded_template_urls data file in the site's data directory. See %s" $.Name $.Position }}
22 {{- end }}
23 {{- else }}
24 {{- errorf "The %q shortcodes requires a named or positional parameter, the file name of the embedded template, excluding its extension. See %s" .Name .Position }}
25 {{- end -}}