Tutorials References Exercises Sign Up Menu
Create Website Get Certified Pro

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 }}