title: <.Chart.Name>: can't evaluate field Chart in type string
body: <p>When I deploy the following I get this error:</p>
  
  <pre><code>{{- if .Values.front.ingress.enabled -}}
  {{- $fullName := include "marketplace.fullname" . -}}
  {{- $ingressPaths := .Values.front.ingress.paths -}}
  apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: {{ $fullName }}-{{ .Values.environment }}-front
    labels:
      app.kubernetes.io/name: {{ include "marketplace.name" . }}-{{ .Values.front.name }}
      helm.sh/chart: {{ include "marketplace.chart" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}-{{ .Values.front.name }}
      app.kubernetes.io/managed-by: {{ .Release.Service }}
    {{- with .Values.front.ingress.annotations }}
    annotations:
      {{- toYaml . | nindent 4 }}
    {{- end }}
  spec:
  {{- if .Values.front.ingress.tls }}
    tls:
    {{- range .Values.front.ingress.tls }}
      - hosts:
        {{- range .hosts }}
          - {{ . | quote }}
        {{- end }}
        secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
    rules:
    {{- range .Values.front.ingress.hosts }}
      - host: {{ . | quote }}
        http:
          paths:
      {{- range $ingressPaths }}
            - path: /
              backend:
                serviceName: {{ include "marketplace.name" . }}-{{ $.Values.front.name }}
                servicePort: 3000
      {{- end }}
    {{- end }}
  {{- end }}
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>  Error: UPGRADE FAILED: render error in "marketplace/templates/front-ingress.yaml": template: marketplace/templates/front-ingress.yaml:36:30: executing "marketplace/templates/front-ingress.yaml" at &lt;include "marketplace...&gt;: error calling include: template: marketplace/templates/_helpers.tpl:6:18: executing "marketplace.name" at &lt;.Chart.Name&gt;: can't evaluate field Chart in type string
  </code></pre>
  
  <p><code>marketplace.name</code> is defined in _helpers.tpl: </p>
  
  <pre><code>{{- define "marketplace.name" -}}
  {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
  {{- end -}}
  </code></pre>
  
  <p><code>.Chart.Name</code> is an internal variable and the order of preference is explained <a href="https://github.com/helm/helm/issues/2913#issuecomment-328609510" rel="noreferrer">here</a> but even setting <code>nameOverride</code> the error is the same.</p>
  
  <p>The strange thing is if I remove this template, <code>.Chart.Name</code> works fine within any other template so I think the problem is related to the scopes of the <code>range</code> used.</p>
  
  <p>Values used:</p>
  
  <pre><code>front:
    ingress:
      enabled: true
      annotations:
        kubernetes.io/ingress.class: nginx-int
        nginx.ingress.kubernetes.io/rewrite-target: /
        nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
      paths:
        - /
      hosts:
        - myhost.mydomain.cloud
      tls: []
  </code></pre>