github.com/rabbouni145/gg@v0.47.1/docs/content/en/functions/safeHTMLAttr.md (about)

     1  ---
     2  title: safeHTMLAttr
     3  # linktitle: safeHTMLAttr
     4  description: Declares the provided string as a safe HTML attribute.
     5  godocref: https://golang.org/src/html/template/content.go?s=1661:1676#L33
     6  date: 2017-02-01
     7  publishdate: 2017-02-01
     8  lastmod: 2017-02-01
     9  categories: [functions]
    10  menu:
    11    docs:
    12      parent: "functions"
    13  keywords: [strings]
    14  signature: ["safeHTMLAttr INPUT"]
    15  workson: []
    16  hugoversion:
    17  relatedfuncs: []
    18  deprecated: false
    19  aliases: []
    20  ---
    21  
    22  Example: Given a site-wide `config.toml` that contains this menu entry:
    23  
    24  ```
    25  [[menu.main]]
    26      name = "IRC: #golang at freenode"
    27      url = "irc://irc.freenode.net/#golang"
    28  ```
    29  
    30  * <span class="bad">`<a href="{{ .URL }}">` &rarr; `<a href="#ZgotmplZ">`</span>
    31  * <span class="good">`<a {{ printf "href=%q" .URL | safeHTMLAttr }}>` &rarr; `<a href="irc://irc.freenode.net/#golang">`</span>
    32