Skip to content
Zotonic
  • Start
  • Cookbook
  • Reference
  • Releases

Live search

Search across all Zotonic content

Type at least two characters

Results are matched against titles, summaries and topics as you type.

Filters · mod_base
  • Reference
  • Frontend developer
  • Template filter
  • JavaScript
  • Security

escapejs

Module

mod_base

Escapes the value for insertion in JavaScript output.

For example:

{{ value|escapejs }}

When the value is he'llo then the output is he\x27llo.

Internally, this calls z_utils:js_escape/1 to perform the escaping.

Note: when generating JSON output, be sure to use filter#escapejson, as JSON escaping is subtly different from JS escaping.

Edit on GitHub

Related documentation

Filters

sanitize_url

Sanitize an URL. Removes URLs that might be dangerous, like javascript: URLs.

Filters

pickle

Pickle an Erlang value so that it can be safely submitted with a form.

Filters

escape_check

Ensures thant an HTML escaped value is properly escaped.

Filters

escape

HTML escape a text. Escapes all reserved HTML characters in the value. Escaped strings are safe to be displayed in a HTML page. When you…

Filters

striptags

Removes all HTML tags from the value.

Filters

log_format_stack

Escapes and formats a Javascript string with a stack trace to readable HTML.

Filters

sanitize_html

Sanitize a HTML code. Removes elements and attributes that might be dangerous, like <script> elements.

Filters

escape_link

Convert any URLs in a plaintext into HTML links, with adding the rel="nofollow" attribute, and replaces all newlines with <br> tags.

Filters

force_escape

HTML escapes a text.

GitHub © 2026 Zotonic