title: How to have short circuit with and/or in text/template
body: <p>I have this Go template:</p>
  
  <pre><code>{{ if and $b.Trigger $b.Trigger.Name }} 
    Name is {{ $b.Trigger.Name }}.
  {{ else }}
    ...other stuff...
  {{ end }}
  </code></pre>
  
  <p>I'm trying to get this template to do:</p>
  
  <pre><code>if b.Trigger != nil &amp;&amp; $b.Trigger.Name != "" { ...
  </code></pre>
  
  <p>however it doesn't work, because as <a href="https://godoc.org/text/template" rel="noreferrer">text/template godoc</a> says, both arguments to and/or functions are evaluated. </p>
  
  <p>When the <code>$b.Trigger.Name</code> is evaluated, it errors out because <code>$b.Trigger</code> can be nil. So it returns error: </p>
  
  <blockquote>
    <p><code>template: builds.html:24:46: executing "content" at &lt;$b.Trigger.Name&gt;: can't evaluate field Name in type *myType</code></p>
  </blockquote>
  
  <p>I tried refactoring this to:</p>
  
  <pre><code>{{ if and (ne $b.Trigger nil) (ne $b.Trigger.Name "") }}
  </code></pre>
  
  <p>and weird enough, this fails as well, it says I can't compare $b.Trigger with nil, which doesn't make sense because that field is a pointer type:</p>
  
  <blockquote>
    <p><code>template: builds.html:24:31: executing "content" at &lt;ne $b.Trigger nil&gt;: error calling ne: invalid type for comparison</code></p>
  </blockquote>
  
  <p>Any ideas?</p>