mirror of
https://github.com/golang/go
synced 2024-11-13 18:40:22 -07:00
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: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
5e755e9d6d
commit
a2a8396f53
@ -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.
|
// The following example is duplicated in text/template; keep them in sync.
|
||||||
|
|
||||||
func ExampleTemplate_block() {
|
func ExampleTemplate_block() {
|
||||||
|
Loading…
Reference in New Issue
Block a user