title: Iterating through ruby array of hashes in HAML
body: <p>I have an array of hashes that I am passing to a HAML page.</p>
  
  <pre><code>array = [{"name" =&gt; "a", "age" =&gt; 1}, {"name" =&gt; "b", "age" =&gt; 2}]
  </code></pre>
  
  <p>I want to iterate and display this information. I have tried doing this</p>
  
  <pre><code>#{locals[:array]}.each do |#{:value}|
  %h2 #{:value["name"]}
  </code></pre>
  
  <p>But it doesn't work. The value of the whole hash just get displayed. How do I iterate and display these elements?</p>
  
  <p>In pseudocode, I want to do the following:</p>
  
  <pre><code>for each element in array:
  print element["name"] // I want to display this information in different HTML tags.
  print element["age"]
  </code></pre>
  
  <p>UPDATE: This is my HAML file.</p>
  
  <pre><code>!!!
  %html
    %head
      %link{:href =&gt; "css/batchscreen.css", :rel =&gt; "stylesheet", :type =&gt; "text/css"}/
    %body
      .container
        locals[:array].each do |element|
        .story
          %h2 Name: #{element['name']}
  </code></pre>