weppos / breadcrumbs_on_rails

A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
https://simonecarletti.com/code/breadcrumbs-on-rails
MIT License
944 stars 188 forks source link

Hide the breadcrumbs if none present #124

Closed DaniG2k closed 6 years ago

DaniG2k commented 6 years ago

Hello,

I'm trying to hide the breadcrumbs from my layout if there are no specified breadcrumbs present. I am using = render_breadcrumbs tag: :li, separator: '' in the application layout file, but would like to change this and only have it output if I indeed have breadcrumbs in the controller (like = render_breadcrumbs tag: :li, separator: '' if breadcrumbs_present?)

Is this possible? I am not seeing any helper methods to check whether breadcrumbs are present or if there's content_for breadcrumbs.

Thanks in advance!

weppos commented 6 years ago

You can use:

if breadcrumbs.any?