We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
▶ go version && go env go version go1.11rc2 darwin/amd64 GOARCH="amd64" GOBIN="" GOCACHE="/Users/bep/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/bep/go" GOPROXY="" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/n6/s_85mm8d31j6yctssnmn_g1r0000gn/T/go-build909831316=/tmp/go-build -gno-record-gcc-switches -fno-common" ▶ uname -a Darwin MacBook-Pro.local 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
package main import ( "bytes" "html/template" "log" "strings" ) func main() { data := map[string]interface{}{ "style": template.HTMLAttr("background-image: url(../images/logo.png)"), } tpl := ` <section style="{{ .style }}"> </section> ` var buf bytes.Buffer tmpl, err := template.New("").Parse(tpl) if err != nil { log.Fatal(err) } if err := tmpl.Execute(&buf, data); err != nil { log.Fatal(err) } result := strings.TrimSpace(buf.String()) if !strings.Contains(result, "background-image") { log.Fatal(result) } }
The above program prints:
<section style="ZgotmplZ"> </section>
The text was updated successfully, but these errors were encountered:
Using template.CSSworks, which also is the correct for my use case. Closing this.
template.CSS
package main import ( "bytes" "html/template" "log" "strings" ) func main() { data := map[string]interface{}{ "style": template.CSS("background-image: url(../images/logo.png)"), } tpl := ` <section style="{{ .style }}"> </section> ` var buf bytes.Buffer tmpl, err := template.New("").Parse(tpl) if err != nil { log.Fatal(err) } if err := tmpl.Execute(&buf, data); err != nil { log.Fatal(err) } result := strings.TrimSpace(buf.String()) if !strings.Contains(result, "background-image") { log.Fatal(result) } }
Sorry, something went wrong.
No branches or pull requests
The above program prints:
The text was updated successfully, but these errors were encountered: