mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-15 18:15:57 +00:00
Improve safeHTMLAttr explanation
This commit is contained in:
1 parent
b64cbce2ec
commit
5091bf6a0f
1 file changed
+5
-1
@@ -34,7 +34,7 @@ Will produce:
|
|||||||
|
|
||||||
`ZgotmplZ` is a special value, inserted by Go's [template/html] package, that indicates that unsafe content reached a CSS or URL context.
|
`ZgotmplZ` is a special value, inserted by Go's [template/html] package, that indicates that unsafe content reached a CSS or URL context.
|
||||||
|
|
||||||
To override the safety check, use the `safeHTMLAttr` function:
|
To indicate that the HTML attribute is safe:
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ range site.Menus.main }}
|
{{ range site.Menus.main }}
|
||||||
@@ -42,4 +42,8 @@ To override the safety check, use the `safeHTMLAttr` function:
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
As demonstrated above, you must pass the HTML attribute name _and_ value through the function. Applying `safeHTMLAttr` to the attribute value has no effect.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
[template/html]: https://pkg.go.dev/html/template
|
[template/html]: https://pkg.go.dev/html/template
|
||||||
Reference in new issue
Block a user