Add an inner <ul> list inside nav_link_to helper

Hi Guys,

I have this helper code and using it well on some projects. But I want it somehow to be able to add an inner
< ul > list.

Here’s the code I use for the haml files

nav_link_to 'Dashboard', 'block layout', 'admin-dashboard.html'

And here’s the helper code

  def nav_link_to name, icon, url
    path = request.path
    class_name = (path == url) ? ' class="active"' : ''
    "<li#{class_name}><a href=\"#{url}\"><i class=\"icon #{icon}\"></i>#{name}</a></li>"
  end

I would like to have an output like this below:

<ul>
          <li class="active"><a href="admin-dashboard.html"><i class="icon block layout"></i>???</a></li>
          <li><a href="admin-links.html"><i class="icon linkify"></i>???</a>
            <ul class="dropdown">
              <li><a href="admin-links.html"><i class="icon linkify"></i>???</a></li>
              <li><a href="admin-links.html"><i class="icon linkify"></i>???</a></li>
            </ul>
          </li>
        </ul>

Thanks in advance!

Hello @DavidMandeeli

I think you can use content_tag

Here is the documentation http://apidock.com/rails/ActionView/Helpers/TagHelper/content_tag

But if you want to build a custom nav i suggest you another simple idea .yml + .html files

Define all your datas in a yml file

Call a view file with your HTML DOM

https://github.com/flexbox/davidl/blob/master/source/views/_social.html.slim

Cheers!