This is a plugin meant for Jekyll.
This filter is described at the Shopify Liquid wiki, but somehow didn't make it into the general repository.
Just plop this guy in your _plugins directory and use it like this:
var title = {{ page.title | json }};
Easy!
Ideally, I'd put it in my application's own module, but I didn't want to make something up off the cuff, so there we are. I figured out the "register the module in the module block" trick pretty quickly because I'm lazy and hate retyping anything longer than five characters!
You can even do this with an anoymous module, but I think that might be getting a little nasty. I'll leave figuring that one out up to you, if you really want to. :D
Hope you enjoy learning Ruby as much as I have. :Ɔ