Skip to content

Instantly share code, notes, and snippets.

@Darep
Created February 26, 2013 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Darep/5036748 to your computer and use it in GitHub Desktop.
Save Darep/5036748 to your computer and use it in GitHub Desktop.
<!-- source/layouts/layout.html.erb -->
<ul class="nav-float products">
<% for cat in data.products.main_categories do %>
<li>
<h4>
<% link_to cat.url do %>
<%= cat.name %>
<% end %>
</h4>
<ul>
<% for child in cat.category.children do %>
<li>
<% link_to child.category.url do %>
<%= child.category.name %>
<% end %>
</li>
<% end %>
</ul>
</li>
<% end %>
</ul>
# data/products.yml
categories:
- category: &id100
name: Kategoria 1
url: /tuotteet/kategoria-1.html
children:
- category: &id101
name: Alikategoria
url: /tuotteet/kategoria-1/alikategoria.html
- category: &id102
name: Alikategoria 2
url: /tuotteet/kategoria-1/alikategoria-2.html
- category: &id200
name: Jotku tuotteet
url: /tuotteet/jotku-tuotteet.html
children:
- category: &id201
name: Julisteet
url: /tuotteet/jotku-tuotteet/julisteet.html
- category: &id202
name: Tarrat
url: /tuotteet/jotku-tuotteet/tarrat.html
main_categories:
- *id100
- *id200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment