codeplant/simple-navigation

Add HTML inside a menu item text?

Rubytastic2 opened this issue · 1 comments

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

    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