title: Combining two if conditions into one
body: <p>The below works</p>
  
  <pre><code>{{- if hasKey (index $envAll.Values.policy) "type" }} 
  {{- if has "two-wheeler" (index $envAll.Values.policy "type") }}
  &lt;code goes here&gt;
  {{- end }}
  {{- end }}
  </code></pre>
  
  <p>while the below fails with "runtime error: invalid memory address or nil pointer dereference"</p>
  
  <pre><code>{{- if and (hasKey (index $envAll.Values.policy) "type") (has "two-wheeler" (index $envAll.Values.policy "type")) }}
  &lt;code goes here&gt;
  {{- end}}
  </code></pre>
  
  <p>There is no list by name "type" declared under $envAll.Values.policy.</p>
  
  <p>In Go, if the right operand is evaluated conditionally, why does the last condition gets evaluated in the second code snippet? How do I solve it?</p>
  
  <p><strong>Edit</strong> (since it marked as duplicate):
  Unfortunately, I cannot use embedded {{ if }} like it is mentioned in the other post.</p>
  
  <p>I simplified my problem above. I actually have to achieve this...</p>
  
  <pre><code>{{if or (and (condition A) (condition B)) (condition C)) }}
      &lt;code goes here&gt;
  {{ end }}
  </code></pre>