FAQ
Ah, thank you Doug!

I think you've shown me how I should turn my example on its head:

baseTempl := `Message is: {{template "content" . }}`

hello, _ := templates.New("hello").Parse(` {{define "content"}}Hello
World{{end}} {{template "base" . }}`)
hello.New("base").Parse(baseTempl)
goodbye, _ := templates.New("goodbye").Parse(`{{define "content"}}Goodbye,
cruel world!{{end} {{template "base" .}}`)
goodbye.New("base").Parse(baseTempl)

Then

hello.Execute(w, data)

or

goodbye.Execute(w, data)

gives me exactly what I want: full templating goodness with a single
parse-preparation phase.

Many thanks,
Craig

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 4 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 19, '13 at 4:27a
activeApr 20, '13 at 2:10p
posts4
users2
websitegolang.org

2 users in discussion

Craig Mason-Jones: 3 posts Dougx: 1 post

People

Translate

site design / logo © 2021 Grokbase