I have a title renderer in my application.html.slim:
title
- if content_for?(:title)
= yield(:title)
- else
| My another title
If there is a content_for :title block, than I yield it. Other way, I render default text 'my another title' in title tag.
All works great, but it seems that code above little dirty. Is there any way to refactor it?
Regards, Alex
I'm not certain whether the following syntax is supported by Slim, but a possible alternative would be a single line ternary output:
title = content_for?(:title) ? yield(:title) : 'My default title'