remove_html

Remove selected HTML elements and their contents.

Syntax

{{ value | remove_html:"script" }}{{ value | remove_html:("script", ".ad") }}

Example

01

Basic usage

InputTS
1{2  "html": "<p>Keep</p><script>remove()</script>"3}
TemplateKNAP
1{{ html | remove_html:"script" }}
OutputKNAP
1<p>Keep</p>

Behavior

  • Unlike remove_tags, this removes the matched element and everything inside it.
  • Requires browser-compatible DOM globals and the knap/html preset.