title: yield if content, render something otherwise (Rails 3)
body: <p>I've been away from Rails for a while now, so maybe I'm missing something simple.</p>
  
  <p>How can you accomplish this:</p>
  
  <pre><code>&lt;%= yield_or :sidebar do %&gt;
    some default content
  &lt;% end %&gt;
  </code></pre>
  
  <p>Or even:</p>
  
  <pre><code>&lt;%= yield_or_render :sidebar, 'path/to/default/sidebar' %&gt;
  </code></pre>
  
  <p>In the first case, I'm trying:</p>
  
  <pre><code>def yield_or(content, &amp;block)
    content_for?(content) ? yield(content) : yield
  end
  </code></pre>
  
  <p>But that throws a 'no block given' error.</p>
  
  <p>In the second case:</p>
  
  <pre><code>def yield_or_render(content, template)
    content_for?(content) ? yield(content) : render(template)
  end
  </code></pre>
  
  <p>This works when there's no content defined, but as soon as I use content_for to override the default content, it throws the same error.</p>
  
  <p>I used <a href="https://stackoverflow.com/questions/2611278/rails-3-yield-return-or-callback-wont-call-in-view-yieldsidebar-rend">this</a> as a starting point, but it seems it only works when used directly in the view.</p>
  
  <p>Thanks!</p>