def htmlsafe_dumps(obj, **kwargs):
 rv = dumps(obj, **kwargs).replace(u'<', u'\\u003c').replace(u'>', u'\\u003e').replace(u'&', u'\\u0026').replace(u"'", u'\\u0027')
 if (not _slash_escape):
  rv = rv.replace('\\/', '/')
 return rv

def htmlsafe_dumps ( obj , ** kwargs ) : rv = dumps ( obj , ** kwargs ) . replace ( u'<' , u'\\u003c' ) . replace ( u'>' , u'\\u003e' ) . replace ( u'&' , u'\\u0026' ) . replace ( u"'" , u'\\u0027' ) if ( not _slash_escape ) : rv = rv . replace ( '\\/' , '/' ) return rv
works exactly like :func:dumps but is safe for use in <script> tags .