Tutorials References Exercises Videos Menu
Create Website Get Certified Upgrade

Template Filter - escapejs


Example

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.


Syntax

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

{{ value|escapejs }}