Add Slashes Modifier
Modifies a string by adding backslashes before characters that need to be escaped. These characters are:
- single quote
' - double quote
" - backslash
\ - NUL (the null byte)
This uses PHP's addslashes(). It does not encode a complete JavaScript string; use an appropriate JSON encoder when passing data to JavaScript.
summary: >
"I'm not listening!" said the small, strange creature.
{{ summary | add_slashes }}
{{ Statamic::modify($summary)->addSlashes() }}
\"I\'m not listening!\" said the small, strange creature.