我想知道有哪些关于使用Go html/templates的好的、最新的资源,特别是在解析html文件和处理列表方面。我发现 Hoka Poka 网站,但它似乎已过时。
Set
类型已不再存在。 - Mike Samuel"html/template"相关的模板代码片段可以在文档的这里找到。
Contexts
Assuming {{.}} is
O'Reilly: How are <i>you</i>?
, the table below shows how {{.}} appears when used in the context to the left.
Context {{.}} After {{.}} O'Reilly: How are <i>you</i>? <a title='{{.}}'> O'Reilly: How are you? <a href="/{{.}}"> O'Reilly: How are %3ci%3eyou%3c/i%3e?
测试套件有许多示例:https://code.google.com/p/go/source/browse/src/html/template/escape_test.go
如果想要查看模板的实际应用,请查看godoc
源代码。从http://code.google.com/p/go/source/browse/src/cmd/godoc/godoc.go#642开始是一个很好的起点。
http://blog.zmxv.com/2011/09/go-template-examples.html 包含了新的Go模板包的一系列代码片段。
template
而不是 html/template
。 - Mike Samuel
text/template
还是html/template
? - Matt K