Improve consistency of handling shrotcode attributes

This commit is contained in:
Alex Shpak
2025-10-12 13:27:05 +02:00
parent 6c9e2a1918
commit 836a8a82d6
15 changed files with 140 additions and 34 deletions
+5 -6
View File
@@ -1,11 +1,10 @@
{{- $destination := partial "docs/links/portable-image" (dict "Page" .Page "Destination" (.Get "src")) -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"keep" (slice "id" "class" "tabindex" "alt" "title" "loading")
) -}}
<label class="book-image" for="book-image-toggle-{{ .Ordinal }}">
<input class="hidden toggle" type="checkbox" id="book-image-toggle-{{ .Ordinal }}" />
<img src="{{ $destination | safeURL }}"
{{- with .Get "alt"}} alt="{{ . }}"{{ end -}}
{{- with .Get "title"}} title="{{ . }}"{{ end -}}
{{- with .Get "loading"}} loading="{{ . }}"{{ end -}}
{{- with .Get "class"}} class="{{ . }}"{{ end -}}
/>
<img src="{{ $destination | safeURL }}" {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }} />
</label>
{{- /* remove whitespaces */ -}}