deface icon indicating copy to clipboard operation
deface copied to clipboard

error on `:javascript` with variable expansion in haml original

Open wvengen opened this issue 10 years ago • 7 comments

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?

wvengen avatar Apr 03 '14 18:04 wvengen

For comparison: when the javascript is just

:javascript
  alert('hi')

the deface output becomes

<script>
  alert('hi')
</script>

giving no error.

wvengen avatar Apr 03 '14 18:04 wvengen

Facing precisely the same issue. @wvengen did you ever found a solution?

designgrill avatar Jan 23 '15 09:01 designgrill

Renaming the affected partial by appending .deface seems to work. Don't know why though.

designgrill avatar Jan 23 '15 10:01 designgrill

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 avatar Jan 27 '15 06:01 wvengen

@wvengen Thanks. Thats what I ended up using as well.

designgrill avatar Feb 13 '15 18:02 designgrill

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.

joeherm avatar Oct 18 '17 21:10 joeherm

this stuff is still alive!

sad

krtschmr avatar Feb 13 '19 06:02 krtschmr