Is it possible to add sub-items to a YML list?
Given the following YML format, is it possible, or advisable to map URLs
so that components like nav lists can be both populated and linked?
It can be populated:
products:
- Wizzy Widgets
- Doohickeys
- Thingamabobbers
renders via the following ERB (where the file is /data/product_types.yml):
<% data.product_types.products.each do |product_type| %>
<li><a href="#"><%= product_type %></a></li>
<% end %>
to output the following markup
<li><a href="#">Wizzy Widgets</a></li>
<li><a href="#">Doohickeys</a></li>
<li><a href="#">Thingamabobbers</a></li>
but can it be linked also
products:
- Wizzy Widgets:
- url: "/wizzy-widgets"
- Doohickeys:
- url: "/doohickeys"
- Thingamabobbers
- url: "/thingamabobbers"
through ERB like so:
<% data.product_types.products.each do |product_type, product_url| %>
<li><a href="<%= product_url %>"><%= product_type %></a></li>
<% end %>
so that it outputs the following markup?
<li><a href="/wizzy-widgets">Wizzy Widgets</a></li>
<li><a href="/doohickeys">Doohickeys</a></li>
<li><a href="/thingamabobbers">Thingamabobbers</a></li>
I know this particular example doesn't work. I'm just trying to give an
example of what I'm looking to do. Is this a bad practice? If so, how
would you approach it?
No comments:
Post a Comment