Content_for and view, controller, and default hierarchy

I am trying to accomplish a hierarchy for my sidebar content using
yield :sidebar and content_for :sidebar. What is the best way to set
up the content_for hierarchy such that the following pseudo code is
true.

if :sidebar code in View
display View :sidebar
elsif :sidebar code in Controller
display Controller :sidebar
else
display Default :sidebar

Thanks in advance.