go-templates Questions
2
GoLand has syntax support on Go html files with the file extension of .gohtml
So what about Go text files? Does GoLand support that as well? .tmpl is supported by vim-go but not GoLand.
Taxable asked 14/3, 2019 at 19:7
5
Solved
So I would like to somehow get all of my {{ .blahblah }} actions defined in a template as slice of strings.
For example if I have this template:
<h1>{{ .name }} {{ .age }}</h1>
I ...
Sowers asked 14/11, 2016 at 8:33
2
Solved
The below works
{{- if hasKey (index $envAll.Values.policy) "type" }}
{{- if has "two-wheeler" (index $envAll.Values.policy "type") }}
<code goes here>
{{- end }}
{{- end }}
while the bel...
Germane asked 1/4, 2019 at 23:3
1
Solved
I was trying to put the if condition in a single line of the helm template:
- name: ENV_VARIABLE
value: {{- if .Values.condition }}"Value1"{{- else }}"Value2"{{- end }}
Howeve...
Nodababus asked 2/6, 2022 at 7:46
3
Solved
My City struct is like this:
type City struct {
ID int
Name string
Regions []Region
}
And Region struct is:
type Region struct {
ID int
Name string
Shops []Destination
Masters []Master
...
Shere asked 25/3, 2018 at 6:41
4
Solved
I am trying to achieve a very simple thing in a Go template and failing!
The range action allows me to iterate through an array along with its zero-based index, as so:
{{range $index, $element :=...
Primaveras asked 5/9, 2014 at 15:59
2
Solved
Currently I am having an issue related to assign a Golang variable to a Javascript variable. I am using the Golang templates, so, from the backend I sent a JSON variable, just like this:
var c []...
Criticize asked 3/8, 2017 at 15:19
5
Solved
Helm charts define helper templates in _helpers.tpl which are used to create normalized names for the services. The standard form of the template for a service (DNS) name is:
{{- define "postg...
Heighho asked 13/12, 2017 at 11:31
3
Solved
I want to pass two data objects to Go Template. One is a MongoDB query result and other is an integer array.
MongoDB Query:-
var results []User
sess, db := GetDatabase()
defer sess.Close()
c := d...
Trudy asked 5/2, 2016 at 12:18
4
Solved
I found this documentation to join two strings, but this doesn't work inside go templates.
Is there a way to join strings inside a go template?
Austral asked 18/8, 2016 at 16:16
3
Solved
I have code like this:
package main
import (
"text/template"
"os"
)
func main() {
type Map map[string]string
m := Map {
"a": "b",
"c": "d",
}
const temp = `{{range $key, $value := $}}key...
Sweated asked 8/3, 2017 at 3:37
3
Solved
$ helm version
version.BuildInfo{Version:"v3.3.0", GitCommit:"8a4aeec08d67a7b84472007529e8097ec3742105", GitTreeState:"dirty", GoVersion:"go1.14.6"}
So I ha...
Keeping asked 28/8, 2020 at 10:53
3
Go places <no value> as the result of a the template expansion
when no value is present for a particular template parameter.
Is there any way to prevent this?
All I can think of right now is...
Subarid asked 20/4, 2018 at 3:49
3
Solved
I'm trying to use a helm template helper to filter out values from a list in my values.yaml file, based on the value of one of the keys in each list member.
My chart is currently comprised of thes...
Phial asked 11/4, 2020 at 8:1
4
Solved
Given the template:
{{range $i, $e := .SomeField}}
{{if $i}}, {{end}}
$e.TheString
{{end}}
This can output:
one, two, three
If, however, I want to output:
one, two, and three
I'd need to...
Wigwam asked 13/3, 2014 at 1:26
3
Solved
Let's say I have
type Person struct {
Name string
}
func (p *Person) Label() string {
return "This is " + p.Name
}
How can I use this method from a html/template ? I would need something like ...
Monkey asked 17/4, 2012 at 22:32
1
Solved
I'm trying to add ingress to my nginx container.
The following ingress template gives me "parse error (<>/ingress.yaml:71: unexpected EOF)". I went through trying mark possible miss...
Landscape asked 14/9, 2021 at 19:7
4
Solved
I am newbie to golang.
To learn it I have started with a simple web app using gin framework.
I have followed the gin doc & configured template file but not able to make it work. I am getting an...
Subacute asked 26/6, 2016 at 19:6
6
Solved
How do I make an optional block in the values file and then refer to it in the template?
For examples, say I have a values file that looks like the following:
# values.yaml
foo:
bar: "somethi...
Placid asked 17/1, 2020 at 22:22
2
Solved
I have the following template:
{{if . eq "login failed"}}
<span class="text-error">Incorrect username or password</span>
{{else if . eq "login success"}}
<span class="text-success"&...
Niemi asked 28/6, 2015 at 15:52
3
Solved
In the html/template (and text/template) packages, template.New has the following signature:
func New(name string) *Template
What exactly is the name used for? I've scanned the docs (and a bit o...
Billington asked 16/12, 2016 at 2:24
2
Solved
how can I have multiple conditions in an if statement inside a template?
I tried this code:
{{ if .condition1 && .condition2 }}
<!-- SHOW SOMETHING -->
{{ end }}
But it doesn't w...
Outmost asked 26/3, 2017 at 7:52
1
Solved
I am trying to create an HTML template on Golang using Gin Gonic. but there are problems when rendering the template that I made to produce a web view (the result is blank). Is there something wron...
Sullage asked 16/3, 2021 at 15:39
2
I have this Go template:
{{ if and $b.Trigger $b.Trigger.Name }}
Name is {{ $b.Trigger.Name }}.
{{ else }}
...other stuff...
{{ end }}
I'm trying to get this template to do:
if b.Trigger != ...
Lettered asked 16/6, 2017 at 6:39
2
Solved
im trying to a loop with a range in helm but using 2 variables, what i have..
values.yaml
master:
slave1:
- slave1value1
- slave1value2
slave2:
- slave2value1
- slave2value2
My actual loop...
Material asked 27/5, 2021 at 20:59
© 2022 - 2024 — McMap. All rights reserved.