HubSpot HUBL
Escape

Example Lottie

Operations (opens in a new tab) Filters (opens in a new tab)

{% set escape_string = "<div>This markup is printed as text</div>" %} 
{{ escape_string|escape_html }}
 
{% for content in contents %}
  {{ content.blog_post_author|tojson }}
{% endfor %}
 
{% set escape_string = "\tThey said 'This string can safely be inserted into JavaScript.'" %}
{{ escape_string|escape_js }}
 
 
{% set escape_string = "<script>alert('oh no!')</script>" %}
{% require_js position="head" %}
<script data-search_input-config="config_{{ name }}" type="application/json">
{
  "autosuggest_results_message": "{{ escape_string|escapejson }}"
}
</script>
{% end_require_js %}