#NEWLINE# def _js_string_filter( value ) : #NEWLINE# #INDENT# 'Converts a value to a JSON string for use in JavaScript code.' #NEWLINE# string = json . dumps ( value ) #NEWLINE# replacements = [ ( '\\' , '\\\\' ) , ( '"' , '\\"' ) , ( "'" , "\\'" ) , ( '\n' , '\\n' ) , ( '\r' , '\\r' ) , ( '\x08' , '\\b' ) , ( '<' , '\\u003c' ) , ( '>' , '\\u003e' ) , ( '&' , '\\u0026' ) ] #NEWLINE# for replacement in replacements : #NEWLINE# #INDENT# string = string . replace ( replacement [ 0 ] , replacement [ 1 ] ) #NEWLINE# #UNINDENT# return jinja2 . utils . Markup ( string )