Cast values passed to escape_javascript to string

Calling escape_javascript on anything that's not a string fails since `gsub` is called. Casting as string fixes this.