Interpolation with CoffeeScript HAML filter #42

Open
jacob-carlborg opened this Issue May 13, 2011 · 6 comments

Comments

Projects
None yet
6 participants
@jacob-carlborg

I have a view file written in haml which uses the coffeescript filter and having problem with string interpolation. Since haml uses the #{} syntax for inline ruby and coffeescript uses the same syntax for string interpolation there is a conflict. What happens is that haml will always see the #{} syntax as inline ruby making it basically impossible to use string interpolation in a coffeescript filter. Any idea if this is possible to solve?

@Sutto

This comment has been minimized.

Show comment Hide comment
@Sutto

Sutto Jun 2, 2011

Owner

Honestly, I'm not sure - It's likely solveable but would require using alternative syntax in coffeescript - I believe (but am not sure) that using \# (e.g. \#{} should fix it.

Owner

Sutto commented Jun 2, 2011

Honestly, I'm not sure - It's likely solveable but would require using alternative syntax in coffeescript - I believe (but am not sure) that using \# (e.g. \#{} should fix it.

@ghost ghost assigned Sutto Jun 2, 2011

@jacob-carlborg

This comment has been minimized.

Show comment Hide comment
@jacob-carlborg

jacob-carlborg Jun 2, 2011

Ok, I'll give it a try.

Ok, I'll give it a try.

@brewster1134

This comment has been minimized.

Show comment Hide comment
@brewster1134

brewster1134 Jun 24, 2011

i am having this issue as well. no way to differentiate interpolated ruby from interpolated js. i tried escaping the hash, but it just returns a string with an escape in it (e.g. "\#{ruby_variable}"

i am having this issue as well. no way to differentiate interpolated ruby from interpolated js. i tried escaping the hash, but it just returns a string with an escape in it (e.g. "\#{ruby_variable}"

@iRonin

This comment has been minimized.

Show comment Hide comment
@iRonin

iRonin Aug 11, 2011

Same issue here.

iRonin commented Aug 11, 2011

Same issue here.

@damienbrz

This comment has been minimized.

Show comment Hide comment
@damienbrz

damienbrz Sep 14, 2011

+1

+1

@as016194

This comment has been minimized.

Show comment Hide comment
@as016194

as016194 Sep 15, 2011

To get really hacky, would

"javascript string #{"\#{interpolated javascript string}"} javascript string"

work? Assuming it passes through Haml's filter first, then CoffeeScript compilation.

To get really hacky, would

"javascript string #{"\#{interpolated javascript string}"} javascript string"

work? Assuming it passes through Haml's filter first, then CoffeeScript compilation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment