title: Are recursion functions not supported in .erb templates?
body: <p>Okay so basically I have something like this:</p>
  
  <p><strong>someView.erb</strong></p>
  
  <pre><code> &lt;ul&gt;
      &lt;% @objects.each do |object| %&gt;
        &lt;%= printAllChildObjects(object) %&gt;
      &lt;% end %&gt;
   &lt;/ul&gt;
  </code></pre>
  
  <p><strong>app.rb</strong></p>
  
  <pre><code>def printAllChildObjects(object)
     "&lt;li&gt;#{object.attributes['name']}&lt;/li&gt;"
      if object.children.first.name == "Error"
        break
      else 
        object.elements.first.each do |innerObject| 
           printAllChildObjects(innerObject)
        end
      end
  end
  </code></pre>
  
  <p>TL:DR; I 'm parsing some XML file with REXML (the XML parser that comes built-in with Ruby, I can't use Nokogiri for some ridiculous corporate reasons). This XML file has nodes that may or may not have children nodes nested within them, and a varying number of those at that. I tried my recursive function by using <code>puts</code> statements and observing the terminal, and it works as expected. </p>
  
  <p>BUT, when I try to incorporate the above view file, I instead get empty boxes with three dots instead, i.e., <code>[ ... ]</code> where each object should be printed. The crazy thing is, the number of boxes matches the number of objects and upon inspecting the html with Chrome Dev Tools, you can see  the ENTIRE object node instead of just the <code>object.attributes['name']</code> (i.e just the name attribute in the node). </p>
  
  <p>ALSO, when I remove the recursion call, and just keep the <code>"&lt;li&gt;#{object.attributes['name']}&lt;/li&gt;"</code> part in the function, the HTML works again! So I'm fairly certain the recursion is what is breaking the HTML rendering. Is there some sort of way to get around this? I'd appreciate even the slightest insights.</p>
  
  <p>Oh, and I'm using Sinatra, not Rails.</p>