Initial commit: DOSSIER Hugo website
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
{{/*
|
||||
This utility replaces placeholders in a URL template string.
|
||||
|
||||
Usage:
|
||||
{{ partial "utils/template-url.html" (dict "template" .url "values" (dict "url" $pageURL "title" $pageTitle "markdown_url" $markdownURL)) }}
|
||||
|
||||
Placeholders use the format {key} and values are URL-encoded automatically.
|
||||
*/}}
|
||||
{{- $template := .template -}}
|
||||
{{- $values := .values | default dict -}}
|
||||
|
||||
{{- range $key, $value := $values -}}
|
||||
{{- $placeholder := printf "{%s}" $key -}}
|
||||
{{- $encoded := $value | urlquery -}}
|
||||
{{- $template = replace $template $placeholder $encoded -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return $template -}}
|
||||
Reference in New Issue
Block a user