← hugo-clarity

from `htmlEscape` to `safeHTML` on attr. `title`

82eacb5582f2468b7596622a50253a944a7b8d38 · Piloto do Raio 2 do Centro de Detenção Provisória de Pinheiros (CDP III) cela 308 · Jul 3, 2022 23:42

The attribute `title` of HTML elements **cannot render HTML tags**. Then, the correct is to use safeHTML rather then htmlEscape.
This way we can use HTML tag on `caption` (`featureImageCap`) without rendering escaped HTML (like `<cite>`) on `title` `figure` tag attribute.

+1 −1 · 1 file changed

  • layouts/partials/figure.html +1 −1
diff --git a/layouts/partials/figure.html b/layouts/partials/figure.html
index 4a0f7b1..e5b7afc 100644
--- a/layouts/partials/figure.html
+++ b/layouts/partials/figure.html
@@ -60,7 +60,7 @@
         src="{{ $fileWeb }}"
       {{ end }}
       {{ with $cap }}
-        title="{{ htmlEscape $cap }}"
+        title="{{ safeHTML $cap }}"
       {{ end }}
     />