summaryrefslogtreecommitdiffstats
path: root/docs/content/en/functions/safeHTMLAttr.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/functions/safeHTMLAttr.md')
-rw-r--r--docs/content/en/functions/safeHTMLAttr.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/content/en/functions/safeHTMLAttr.md b/docs/content/en/functions/safeHTMLAttr.md
new file mode 100644
index 000000000..a5ecaa68b
--- /dev/null
+++ b/docs/content/en/functions/safeHTMLAttr.md
@@ -0,0 +1,32 @@
+---
+title: safeHTMLAttr
+# linktitle: safeHTMLAttr
+description: Declares the provided string as a safe HTML attribute.
+godocref: https://golang.org/src/html/template/content.go?s=1661:1676#L33
+date: 2017-02-01
+publishdate: 2017-02-01
+lastmod: 2017-02-01
+categories: [functions]
+menu:
+ docs:
+ parent: "functions"
+keywords: [strings]
+signature: ["safeHTMLAttr INPUT"]
+workson: []
+hugoversion:
+relatedfuncs: []
+deprecated: false
+aliases: []
+---
+
+Example: Given a site-wide `config.toml` that contains this menu entry:
+
+```
+[[menu.main]]
+ name = "IRC: #golang at freenode"
+ url = "irc://irc.freenode.net/#golang"
+```
+
+* <span class="bad">`<a href="{{ .URL }}">` &rarr; `<a href="#ZgotmplZ">`</span>
+* <span class="good">`<a {{ printf "href=%q" .URL | safeHTMLAttr }}>` &rarr; `<a href="irc://irc.freenode.net/#golang">`</span>
+