use %q instead of "%s" for quoted strings
108 if compo.Style == "" {
109 compo.Style = template.HTMLAttr(fmt.Sprintf(`style="%s"`, compo.Padding))
110 } else {
111 compo.Style = template.HTMLAttr(fmt.Sprintf(`style="%s"`, string(compo.Style)+compo.Padding))112 }
113
114 return ComposeHtml(compo.TemplateList, compo.Separation, *compo, "box")
use %q instead of "%s" for quoted strings
106func (compo *BoxAttribute) GetContent() template.HTML {
107
108 if compo.Style == "" {
109 compo.Style = template.HTMLAttr(fmt.Sprintf(`style="%s"`, compo.Padding))110 } else {
111 compo.Style = template.HTMLAttr(fmt.Sprintf(`style="%s"`, string(compo.Style)+compo.Padding))
112 }
Description
%q
is same as "%s"
.
Bad practice
str := fmt.Sprintf("str: "%s"", "Hello World")
// str => str: "Hello World"
Recommended
str := fmt.Sprintf("str: %q", "Hello World")
// str => str: "Hello World"