Hi Denis
I'm aware of that :-) but once I'd got around the 'doh' moment about reading arrays in erb, my later reply was because I then needed two distinct orders from different hashes, on many pages with different values and key orders, but all in this form with numerical keys:
ternhash:
- 2: tern1
- 0: tern2
- 1: tern3
where the values are ordered twice, like this:
* order one: order of appearance in the hash (tern1, tern2, tern3) - not reliable in Ruby <9;
* order two: numerical order of the hash key (tern2, tern3, tern1) - each page's hash has it's own order.
But I couldn't find out how to read a YAML hash by key in erb (@item[:terntest]['0']? @item[:terntest][:0]?... nope, still can't!) so gave up and used the two-array solution, so the YAML in my content files is like this:
terntest:
- tern1
- tern2
- tern3
and for the two orders required, my layouts read it like this:
order one:
<%= @item[:terntest].join(', ') %>
order two:
<%= @item[:terntest][@item[:n][0]] %>, <%= @item[:terntest][@item[:n][1]] %>, <%= @item[:terntest][@item[:n][2]] %>
Whereas if I used a hash, for order two I was expecting to be able to do something like:
<%= @item[:ternhash][:0]] %>, <%= @item[:ternhash][:1]] %>, <%= @item[:ternhash][:2]] %>
But that, and other attempts to read a hash, fail (I'll post another topic). In fact, I'm thinking of writing up simple 'how to read your YAML into erb and loop through arrays and stuff like that' because it's not easy to find. Of course, nanoc itself is not at fault in any of this :-)