title: Printing Ruby inside of javascript using haml
body: <p>I've been having problems trying to print some ruby variables while using haml, inside of my javascript code.</p>
  
  <p>I have a variable called "@matrix" that is a Matrix. What I need to do is print each of the rows of the given matrix and end up with something looking like the following:</p>
  
  <pre><code>  ['Year', 'Sales', 'Expenses'],
    ['2004',  1000, 400],
    ['2005',  1170, 460],
    ['2006',  660, 1120],
    ['2007',  1030, 540]
  </code></pre>
  
  <p>The problem is that I can't seem to get the right format using my ruby variable. I've seen some similar problems in stackoverflow, however even after trying different ways of implementing what I've read, i haven't succeded. </p>
  
  <p>My actual code is the following:</p>
  
  <pre><code>  ['Year', 'Sales', 'Expenses'],
    #{
      for i in 0..@matrix.row_count
        puts @matrix.row(i).to_a.to_s+","
      end
    }
  </code></pre>
  
  <p>Which should give me each row of the matriz (which is just what I want), however the error I'm getting is that the <em>for</em> loop isn't recognized, and what is printed is actually <em>0..66</em>.</p>
  
  <p>Any approach on how to solve this would be greatly appreciated.
  Thanks.</p>