var html = ''; <% if @results.any? %> <% @results.each do |match| %> html += '<%= j PostPresenter.preview(match[:post], :tags => "status:any") %>'; <% end %> <% else %> html += '

No matches found

'; <% end %> $("
").html(html).dialog({title: "Similar Posts", modal: true, width: "600px"});