In Puppet it is possible to lookup variables in files using ERBs,例如:
<% @values.each do |val| -%> Some stuff with <%= val %> <% end -%>
如何使用Go进行相同的操作?
答案 0 :(得分:3)
问题有点不清楚,但Go内置了一个非常强大的模板引擎:https://golang.org/pkg/text/template/
甚至还有一个特殊的HTML扩展包,它根据上下文(属性,标签,文本等)自动转义 - https://golang.org/pkg/html/template/
以上示例如下所示:
{{ range .Values }}
Some stuff with {{ . }}
{{ end }}