In Go's html/template
, you don't have to enclose a template action within double quotes. The html/template
package automatically adds double quotes to your string.
<span title="{{.Title}}">Hello World</span>
<span title={{.Title}}>Hello World</span>
Both examples produce the same HTML:
<span title="This is title">Hello World</span>
This feature is especially helpful when you need to use double quotes within a template action.
Incorrect:
<span title="{{printf "%0.2f" .Score}}">Score</span>
Correct:
<span title={{printf "%0.2f" .Score}}>Score</span>