init
This commit is contained in:
26
layouts/partials/autotooltips.html
Normal file
26
layouts/partials/autotooltips.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{{- $page := . -}}
|
||||
{{- $html := $page.Content -}}
|
||||
|
||||
{{- $items := site.Data.tooltips.items -}}
|
||||
|
||||
{{/* 1: placeholders zetten */}}
|
||||
{{- range $name, $cfg := $items }}
|
||||
{{- $label := $cfg.label -}}
|
||||
{{- $placeholder := printf "__TOOLTIP_%s__" $name -}}
|
||||
{{- $pattern := printf `\b%s\b` $label -}}
|
||||
{{- $html = replaceRE $pattern $placeholder $html -}}
|
||||
{{- end }}
|
||||
|
||||
{{/* 2: placeholders vervangen door tooltip-woord */}}
|
||||
{{- range $name, $cfg := $items }}
|
||||
{{- $label := $cfg.label -}}
|
||||
{{- $key := $cfg.key -}}
|
||||
{{- $text := i18n $key -}}
|
||||
{{- $placeholder := printf "__TOOLTIP_%s__" $name -}}
|
||||
|
||||
{{- $replacement := printf `<span class="tooltip-word" data-tooltip="%s">%s</span>` $text $label -}}
|
||||
|
||||
{{- $html = replace $html $placeholder $replacement -}}
|
||||
{{- end }}
|
||||
|
||||
{{- $html | safeHTML -}}
|
||||
Reference in New Issue
Block a user