title: Ruby methods within Javascript within HAML
body: <p>I have a jQuery script that adds a new field to a form, and this field contains dynamic information from an array. The problem is that I can't figure out how to add an array.each to populate the options of the select field within the javascript without breaking the HAML indentation and causing errors.</p>
  
  <p>Here is my best attempt that does not work:</p>
  
  <pre><code>%script(type="text/javascript")  
    $('#mylink').click(function() {  
    $('#mylink').after('&lt;select&gt;  
    - myarray.each do |options|  
       &lt;option value="#{options.id}"&gt;#{options.name}&lt;/option&gt;  
    &lt;/select&gt;);  
    )};
  </code></pre>
  
  <p>Also tried it with the :javascript filter with no luck.</p>