少于1分钟
将以下英文翻译为中文:
https://gohugo.io/functions/safehtmlattr/
Declares the provided string as a safe HTML attribute.
safeHTMLAttr INPUT
Given a site configuration that contains this menu entry:
config.
=== “yaml”
``` yaml
menu:
main:
- name: IRC
url: irc://irc.freenode.net/#golang
```
=== “toml”
``` toml
[menu]
[[menu.main]]
name = 'IRC'
url = 'irc://irc.freenode.net/#golang'
```
=== “json”
``` json
{
"menu": {
"main": [
{
"name": "IRC",
"url": "irc://irc.freenode.net/#golang"
}
]
}
}
```
Attempting to use the url
value directly in an attribute:
|
|
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.
To override the safety check, use the safeHTMLAttr
function:
|
|