codeplant / simple-navigation

A ruby gem for creating navigations (with multiple levels) for your Rails, Sinatra or Padrino applications. Render your navigation as html list, link list or breadcrumbs.
http://simple-navigation-demo.codeplant.ch/
MIT License
885 stars 136 forks source link

Add HTML inside a menu item text? #196

Closed Rubytastic2 closed 8 years ago

Rubytastic2 commented 8 years ago

Would it be possible to add html inside a

  • item? I would like to add an font awesome icon before the menu item text.

    <div class="fa.fa.bla">my custom menu item text here</div>
          tab.item :educations, "Educations",  employee_profile_educations_path,  :highlights_on => /\beducations/

    Could not find anything in the wiki on how to do this? Could someone please elaborate on this? thank you!

  • andi commented 8 years ago

    You could either add the needed html using javascript or you could use name_generator in your navigation config, here is a snippet of one of my projects:

    navigation.name_generator = Proc.new do |name, item| 
        if item.key == :'current-lang'
          "<i class='fa fa-caret-down'></i> #{name}".html_safe
        elsif item.key == :'lang-label'
          "<label>#{name}</label>".html_safe
        else
          name
        end
    end