Skip to content

Conformance Examples 0.1.0 — Transforms: transform-strip_html

strip_html-simple-tags

Inline tags are removed; their inner text is preserved.

Template

{{ html | strip_html }}

Context

{
    "html": "<p>hello <b>world</b></p>"
}

Output

hello world

strip_html-self-closing-and-attrs

Tags with attributes and self-closing slashes are removed entirely.

Template

{{ html | strip_html }}

Context

{
    "html": "before<br/>middle<img src=\"x\" />after"
}

Output

beforemiddleafter

strip_html-script-body-removed

Both the script tags AND their body are removed (case-insensitive open/close).

Template

{{ html | strip_html }}

Context

{
    "html": "before<SCRIPT>alert('x')</Script>after"
}

Output

beforeafter

strip_html-style-body-removed

Both the style tags AND their body are removed.

Template

{{ html | strip_html }}

Context

{
    "html": "before<style>.a{color:red}</style>after"
}

Output

beforeafter

strip_html-comment-removed

HTML comments are removed.

Template

{{ html | strip_html }}

Context

{
    "html": "before<!-- inline note -->after"
}

Output

beforeafter

strip_html-entities-not-decoded

HTML entities are left intact (no entity decoding). Unescaped interpolation avoids the double-encoding that {{ }} would introduce.

Template

{{{ html | strip_html }}}

Context

{
    "html": "<p>1 &amp; 2</p>"
}

Output

1 &amp; 2

strip_html-no-tags-passthrough

Plain text without tags is unchanged.

Template

{{ html | strip_html }}

Context

{
    "html": "no tags here"
}

Output

no tags here

Source fixture: transforms/transform-strip_html.json