title: erb idiom to handle undefined variable
body: <p>I'm trying to write some puppet .erb, I'd like to handle this "environment" variable if it's:  </p>
  
  <ul>
  <li>undefined  </li>
  <li>a string with newlines  </li>
  <li>an array. </li>
  </ul>
  
  <p>I've got as far as this:</p>
  
  <pre><code>&lt;% Array(environment).join("\n").split(%r{\n}).each do |f| %&gt;
  one line: &lt;%= f %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>But haven't gotten around the undefined case yet.  I've tried this</p>
  
  <pre><code>&lt;% if (defined?(environment)).nil? %?
  &lt;% Array(environment).join("\n").split(%r{\n}).each do |f| %&gt;
  one line: &lt;%= f %&gt;
  &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>but am still getting "(erb):11: undefined local variable or method `environment' for main:Object (NameError)" when trying to test it like this:</p>
  
  <pre><code>ruby -rerb -e "environmentUNDEFINEME= [ 'cronvar=cronval', 'var2=val2' ]; 
  puts ERB.new(File.read('templates/job.erb')).result"
  </code></pre>
  
  <p>Sorry this is so basic, but somebody's got to ask the easy questions.  Any help?</p>