deface
deface copied to clipboard
error on `:javascript` with variable expansion in haml original
When there's :javascript
in a haml template that contains variable expansion with deface active, an error occurs:
undefined local variable or method `_hamlout' for #<#<Class:0x00000005c71d70>:0x0000000663c9e0>
The source is
:javascript
alert('#{"hi"}')
which is compiled (by rake deface:get_result
) to
<%= find_and_preserve(Haml::Filters::Javascript.render_with_options(
"alert('#{"hi"}')\n", _hamlout.options)) %>
I can imagine that _hamlout
in this erb
template gives an error. But why is it there?
For comparison: when the javascript is just
:javascript
alert('hi')
the deface output becomes
<script>
alert('hi')
</script>
giving no error.
Facing precisely the same issue. @wvengen did you ever found a solution?
Renaming the affected partial by appending .deface seems to work. Don't know why though.
Not really, as a workaround I'm putting javascript in a separate file, either a javascript asset, or a partial with just the javascript.
@wvengen Thanks. Thats what I ended up using as well.
Still seeing this issue, the workaround of putting in a separate file works. Any ideas on where to start in on a fix? I'd be happy to help if someone can point me in the right direction.
this stuff is still alive!
sad