@kjk1/

gobook template js html url escape

Go

No description

fork
loading
Files
  • main.go

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5162333928447942","path":"main.go","file":{"path":"main.go","content":{"asEncoding":{"base64":"cGFja2FnZSBtYWluCgppbXBvcnQgKAoJImxvZyIKCSJvcyIKCSJ0ZXh0L3RlbXBsYXRlIgopCgovLyA6c2hvdyBzdGFydApjb25zdCB0bXBsU3RyID0gYGpzIGVzY2FwZSAgOiB7eyBqcyAuSlMgfX0KaHRtbCBlc2NhcGU6IHt7IGh0bWwgLkhUTUwgfX0KdXJsIGVzY2FwZSA6IHt7IHVybHF1ZXJ5IC5VUkwgfX0KYAoKLy8gOnNob3cgZW5kCgpmdW5jIG1haW4oKSB7CgkvLyA6c2hvdyBzdGFydAoJdCA6PSB0ZW1wbGF0ZS5NdXN0KHRlbXBsYXRlLk5ldygicHJpbnQiKS5QYXJzZSh0bXBsU3RyKSkKCglkYXRhIDo9IHN0cnVjdCB7CgkJSlMgICBzdHJpbmcKCQlIVE1MIHN0cmluZwoJCVVSTCAgc3RyaW5nCgl9ewoJCUpTOiAgIGBmdW5jdGlvbiBtZShzKSB7IHJldHVybiAiZm9vIjsgfWAsCgkJSFRNTDogYDxkaXY+dGV4dDwvZGl2PmAsCgkJVVJMOiAgYGh0dHA6Ly93d3cucHJvZ3JhbW1pbmctYm9va3MuaW9gLAoJfQoJZXJyIDo9IHQuRXhlY3V0ZShvcy5TdGRvdXQsIGRhdGEpCglpZiBlcnIgIT0gbmlsIHsKCQlsb2cuRmF0YWxmKCJ0LkV4ZWN1dGUoKSBmYWlsZWQgd2l0aCAnJXMnXG4iLCBlcnIpCgl9CgkvLyA6c2hvdyBlbmQKfQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main

import (
	"log"
	"os"
	"text/template"
)

// :show start
const tmplStr = `js escape  : {{ js .JS }}
html escape: {{ html .HTML }}
url escape : {{ urlquery .URL }}
`

// :show end

func main() {
	// :show start
	t := template.Must(template.New("print").Parse(tmplStr))

	data := struct {
		JS   string
		HTML string
		URL  string
	}{
		JS:   `function me(s) { return "foo"; }`,
		HTML: `<div>text</div>`,
		URL:  `http://www.programming-books.io`,
	}
	err := t.Execute(os.Stdout, data)
	if err != nil {
		log.Fatalf("t.Execute() failed with '%s'\n", err)
	}
	// :show end
}