Is there a way to add parameters (HTML attributes) to HAML filters?
I wanted to do something like this:
:javascript{:'data-turbolinks-eval' => 'false', :foo => 'bar'} if(someCondition){ doSomething(); }
And the result will be:
<script 'data-turbolinks-eval'='false' 'foo'='bar'> if(someCondition){ doSomething(); } </script>
The closest I could get is:
%script{:'data-turbolinks-eval' => 'false', :foo => 'bar'} if(someCondition){ doSomething(); }
The downside is that you cannot backtrack from JS in HAML unless you use the javascript filter. This is fine for multiple lines, but it can get confused quickly.
I am well aware that in most cases, if you finish a complex script in a HAML template, it means that you are doing something wrong and that is not the answer I'm looking for.
javascript ruby filter indentation haml
Jim
source share