Tutorials References Exercises Bootcamp Menu
Sign Up Create Website Get Certified Upgrade

Template Filter - escapejs


Escape a text to use in a JavaScript:

<button onclick="alert('{{ var1|escapejs }}')">Click me</button>
Run Example »

Definition and Usage

The escapejs filter escapes text to be used in JavaScript strings.


Template filters are defined by using a pipe | character followed by the name of the filter.

{{ value|escapejs }}