我有嵌套数组:
book= {"Dan Brown"=>["Angels and Demons", "The Da Vinci Code"], "Dale Carnegie"=>["How to Win Friends and Influence People", "How to Stop Worrying and Start Living"]}
我需要这个 html 结果:
<h3 class="title">Book</h3>
<h4>Dan Brown</h4>
<ul>
<li>Angels and Demons</li>
<li>The Da Vinci Code</li>
</ul>
<h4>Dale Carnegie</h4>
<ul>
<li>How to Win Friends and Influence People</li>
<li>How to Stop Worrying and Start Living</li>
</ul>
无法理解如何通过 erb 模板进行操作。
可能来自这个方法:
book.each {|key, value| puts "#{key} is #{value}" }
但是对我来说这种方法不起作用,我想我无法理解如何使用它。谢谢你的帮助。