title: Check if a variable is undef in puppet template
body: <p>What is the proper way to check if a variable is undef in a puppet template?</p>
  
  <p>In the manifest the variable is defined as follows</p>
  
  <pre><code>$myvar = undef
  </code></pre>
  
  <p>How is this checked in the template?</p>
  
  <p>Is saw the following two variants</p>
  
  <pre><code>&lt;% if @myvar -%&gt;
  &lt;% end -%&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;% if not @myvar.nil? and @myvar -%&gt;
  &lt;% end -%&gt;
  </code></pre>
  
  <p>They both seem to work in my case, but I wonder if the first approach fails in on certain cases?</p>