You could solve this in one of two ways:

1. Switch over to embedding `t` as JSON and concatenating in Javascript, e.g.: [julius| str = "a" + #{toJSON t} + "bc"|]. I think we never ended up adding the aeson instances to shakespeare-js, but I'm in favor of doing so.
2. Writing some escape algorithm on the characters. This would be more complicated.

The reason we haven't implemented the idea that Greg mentions is that it prevents certain use cases, such as interpolating actual Javascript code.


On Wed, Nov 14, 2012 at 12:08 PM, Dmitry Vyal <akamaus@gmail.com> wrote:
Greetings

Recently I stumbled upon an unexpected escaping problem. I hoped Shakespeare templates would solve these forever, but looks like it's not the case.

For example, look at this snippet:
Prelude Text.Julius Data.Text.Lazy Data.Text> let t = "X\"Y\"Z"; j = [julius| str = "a#{t}bc"; |] in putStrLn $ Data.Text.Lazy.unpack $  renderJavascriptUrl (\u env -> Data.Text.pack "") j
 str = "aX"Y"Zbc";

Clearly we have have a problem here. Can something be done with it?

Best wishes,
Dmitry

_______________________________________________
web-devel mailing list
web-devel@haskell.org
http://www.haskell.org/mailman/listinfo/web-devel