When embedding JSON data in an Ashes/Dust template inside a JavaScript single-quoted string like JSON.parse('{json_data|s}'), two escaping issues break at runtime:
The |s filter in Ashes only suppresses HTML escaping — it does nothing for JS string safety.
Create a _json_for_js() helper that post-processes json.dumps output for safe embedding in JS single-quoted strings:
The order matters — backslash escaping must come first. Use ensure_ascii=False in json.dumps so non-ASCII characters pass through as UTF-8 rather than being escaped (which would then get double-escaped).