HAML Data loop is rendering hash symbols

I have a YML file that renders Hash symbols at the end of the loop:

Here’s the screen grab of the rendered HTML:

Here’s the YAML file:

nav:

  • name: The Beers
    link: /the-beers/
  • name: Pub
    link: /pub-sf/
  • name: Tap Room
    link: /tap-room/
  • name: Find Some
    link: /find-some/
  • name: Gear
    link: /shop/
  • name: The Brewery
    link: /the-brewery/
  • name: History
    link: /history/
  • name: Journal
    link: /journal/

Here is the HAML file:

%header{role: “banner”}
%h1= link_to data.config.site.title, “/”, rel: “home”

%nav{role: “navigation”}
%ul
= data.navigation.nav.each do |nav|
%li{nav_active(nav.link)}
= link_to nav.name, nav.link

Sorry if the answer is obvious. I’m new to HAML, so maybe the problem is in my code.

Thanks for the help.

Forgot to include the rendered HTML:

  <nav role='navigation'>
    <ul>
            <li>
        <a href="/the-beers/">The Beers</a>
      </li>
      <li>
        <a href="/pub-sf/">Pub</a>
      </li>
      <li>
        <a href="/tap-room/">Tap Room</a>
      </li>
      <li>
        <a href="/find-some/">Find Some</a>
      </li>
      <li>
        <a href="/shop/">Gear</a>
      </li>
      <li>
        <a href="/the-brewery/">The Brewery</a>
      </li>
      <li>
        <a href="/history/">History</a>
      </li>
      <li>
        <a href="/journal/">Journal</a>
      </li>
[#<Middleman::Util::EnhancedHash link="/the-beers/" name="The Beers">, #<Middleman::Util::EnhancedHash link="/pub-sf/" name="Pub">, #<Middleman::Util::EnhancedHash link="/tap-room/" name="Tap Room">, #<Middleman::Util::EnhancedHash link="/find-some/" name="Find Some">, #<Middleman::Util::EnhancedHash link="/shop/" name="Gear">, #<Middleman::Util::EnhancedHash link="/the-brewery/" name="The Brewery">, #<Middleman::Util::EnhancedHash link="/history/" name="History">, #<Middleman::Util::EnhancedHash link="/journal/" name="Journal">]
    </ul>
  </nav>

Not sure why the EnhancedHash link is rendering.

Hello @benjaminkinzer
Think this is better for a loop

- data.navigation.nav.each do |nav|
  %li{nav_active(nav.link)}
  = link_to nav.name, nav.link

And you can try to organise your datas like this

1 Like

Flexbox, thank you!

Changing the line “= data.navigation.nav.each do |nav|” to “- data.navigation.nav.each do |nav|” worked.

My files do have the proper indentation, but they would not translate in the forums.

Again thank you!

Sorry for the double reply. Just wanted to state that I misunderstood what you were saying about formatting the YAML file. Thank you for the tip. I just reformatted my file.

Cheers!