Shannon -jj Behrens wrote:
Hey guys,

I need a JavaScript escape function.  Let's say I have a variable, and
I'm generating some JavaScript from Cheetah:

    var s = "$s";

I need to make $s safe:

    var s = "$javascript_safe($s)";

Has anyone coded this yet?  Will the same function work for both
single and double quoted strings?  Can I steal some code?

FWIW, Python string literals seem to match Javascript's perfectly (at least the strings repr() produces -- not triple-quoted strings or anything fancy). So you'd do "var s = $repr(str(s))".


--
Ian Bicking  /  [EMAIL PROTECTED]  / http://blog.ianbicking.org
_______________________________________________
Web-SIG mailing list
[email protected]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com

Reply via email to