HeinrichApfelmus / threepenny-gui

GUI framework that uses the web browser as a display.
https://heinrichapfelmus.github.io/threepenny-gui/
Other
439 stars 77 forks source link

Escaping % in ffi call? #132

Closed blitzcode closed 8 years ago

blitzcode commented 8 years ago

Trying to call some client side JS through ffi with any %-sign in the string will fail, i.e.

runFunction $ ffi "document.getElementById('content').innerHTML = \"<div style=\\\"width: 10%\\\"></div>\""

this will trigger the string substitution logic. It seems to silently fail, though. Took me a while to realize what the problem is. I might have missed something, but there's no way to escape a % in the string?

The only way I could make it work was by putting the entire string inside a parameter

runFunction $ ffi "document.getElementById('content').innerHTML = %1" html

That does works and has the added benefit of doing all the quote escaping etc. automatically, but it would still be nice if there was a way to escape % in strings passed to ffi.

HeinrichApfelmus commented 8 years ago

Commit aa0d626e8d8289b7e66839785032527c83d2a36b should do the trick. Could you check that this works?

blitzcode commented 8 years ago

I can now include an escaped %-sign, nothing else seems to have broken either regarding ffi strings, thanks ;-)

HeinrichApfelmus commented 8 years ago

Sounds like it's time to close then. Thanks!