Yield and default case || do not output default case

前端 未结 7 1205
刺人心
刺人心 2021-02-14 15:49

I have a simple yield use case and for some unknown reason the default case is never shown:

In my super_admin layout I have:

<%= yield :body_id || \'s         


        
7条回答
  •  粉色の甜心
    2021-02-14 16:26

    Try <%= yield(:title).presence || 'My Default Title' %>

    Object#presence is equivalent to object.present? ? object : nil (AS 3 rc docs), and essentially allows the traditional syntax with the titles.

提交回复
热议问题