turn a ruby hash into html list

Posted by JAlberto on Stack Overflow See other posts from Stack Overflow or by JAlberto
Published on 2011-01-03T20:43:25Z Indexed on 2011/01/03 20:53 UTC
Read the original article Hit count: 320

Filed under:
|
|

I'm trying to parse a yaml file like this:

a:
 a1:
 a2:
b:
 b1:
  b11:
 b2:

i get a hash like this:

{"a"=>{"a1"=>nil, "a2"=>nil}, "b"=>{"b1"=>{"b11"=>nil}, "b2"=>nil}}

and i want to turn it to a list:

%ul
 %li a
  %ul 
   %li a1
   %li a2
 %li b
  %ul
   %li b1
    %ul
     %li b11
   %li b2

I'm trying to search the most efficent way doesn't matter how deep is the hash

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby