Commit a2a8396f authored by Dmitry Neverov's avatar Dmitry Neverov Committed by Brad Fitzpatrick

html/template: add an example for the Delims method

Change-Id: I7ba55e3f6ebbaae41188316a66a40f994c037ad9
Reviewed-on: https://go-review.googlesource.com/132240
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 5e755e9d
......@@ -123,6 +123,28 @@ func Example_escape() {
}
func ExampleTemplate_Delims() {
const text = "<<.Greeting>> {{.Name}}"
data := struct {
Greeting string
Name string
}{
Greeting: "Hello",
Name: "Joe",
}
t := template.Must(template.New("tpl").Delims("<<", ">>").Parse(text))
err := t.Execute(os.Stdout, data)
if err != nil {
log.Fatal(err)
}
// Output:
// Hello {{.Name}}
}
// The following example is duplicated in text/template; keep them in sync.
func ExampleTemplate_block() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment