英文:
What is the purpose of {{ . }} in YAML?
问题
我知道{{ }}
用于评估表达式。但在Helm charts中,{{ . }}
具体表示什么意思呢?
示例:
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
英文:
I know that {{ }} is used to evaluate expressions. But what does specifically {{ . }} mean in Helm charts?
Example:
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
答案1
得分: 1
你的问题不是关于YAML的,而是关于Go模板。
在Go模板中,{{ }}
用于评估表达式,而.
是指向光标的引用。在你的示例中,光标由range
设置,它会为pullSecrets
中的每个元素评估其主体,并且在每次评估中,光标都会设置为当前元素。
Helm使用Go模板对YAML输入进行预处理。这与YAML本身无关。
英文:
Your question is not about YAML, it is about Go templates.
In Go templates, {{ }}
evaluates expressions and .
is the reference to the cursor. In your example, the cursor is set by range
, which evaluates its body for each element in pullSecrets
, and in each evaluation the cursor is set to the current element.
Helm uses Go templates to preprocess YAML input. This has nothing to do with YAML itself.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论