Top "Go-templates" questions

Go language supports built-in template functionality.

Go template: can't evaluate field X in type Y (X not part of Y but stuck in a {{range}} loop)

Similar question answered here, but I don't think it solves my problem. Let's say you have the following struct: type …

go go-templates
Using conditions inside templates

The use of if statements inside templates really is puzzling me. I'm trying to put a class = "active" inside a …

if-statement go go-templates
Helm: generate comma separated list

Using Helm templates, I'm trying to generate a list of server names based on a number in values.yaml. The …

kubernetes go-templates kubernetes-helm
Go templates with eq and index

Go templates have some unexpected results when using eq with index for me. See this code: package main import ( "os" "…

go go-templates
Last item in a template range

Given the template: {{range $i, $e := .SomeField}} {{if $i}}, {{end}} $e.TheString {{end}} This can output: one, two, three If, …

go go-templates
text/template issue Parse() vs. ParseFiles()

I'm trying to do some simple work with the text/template package. The sample given at the top of template …

go go-templates
Range over string slice in golang template

I have a struct that contains a slice of type string like the following. type Data struct { DataFields []string } Within …

go go-templates
Golang use json in template directly

I'm looking for a way of binding json data directly into a template (without any struct representation in golang) - …

json templates go go-templates
Show default content in a template if an object is nil otherwise show based on the set property

In my template, I would like to include some default meta tags (90% of the time). However, when a specific property …

go go-templates
How to print JSON on golang template?

I need a object in client side, so I converted it to JSON using json.marshal and printed it into …

go go-templates