I just came across the fact that nanoc freezes arrays from the YAML metadata in content files, so won't respond to
shift etc. I have different length lists of tabs on several pages, only the first of which always needs
class="active". Then I want to loop through the remaining array items (omitting the first). I managed this in the layout by using
dup to 'shallow copy' the frozen array, then using
shift on the array copy as follows:
<ul class="tabs">
<li><a class="active" href="#<% t = @item[:tabs].dup; t1 = t.shift %><%= t1 %>"><%= t1 %></a></li>
<% t.each do | i | %>
<li><a href="#<%= i %>"><%= i %></a></li>
<% end %>
</ul>
YAML example:
tabs:
Just wondering if there's a cleaner, DRYer way? I want to hard-code the class into the output - my existing Javascript handles the tabs nicely that way.