Is there a way to use a Ruby loop inside of HAML's :javascript region?

Posted by Jian Lin on Stack Overflow See other posts from Stack Overflow or by Jian Lin
Published on 2010-06-02T22:38:28Z Indexed on 2010/06/02 23:14 UTC
Read the original article Hit count: 144

Filed under:
|
|
|
|

Inside of HAML, can we have a loop inside the :javascript region?

This will work:

- 10.upto(20) do |i|
  :javascript
    document.getElementById('aDiv').innerHTML += '#{i}';

and this will not:

:javascript
  - 10.upto(20) do |i|
    document.getElementById('aDiv').innerHTML += '#{i}';

can the code above also be made to work as well?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ruby