Skip to content

Conformance Examples 0.1.0 — Render: html-escaping

html-escape-ampersand

{{ }} escapes & to & (covers the '&' branch of escapeHTML).

Template

{{ /s }}

Context

{
    "s": "a&b"
}

Output

a&b

html-escape-less-than

{{ }} escapes < to < (covers the '<' branch of escapeHTML).

Template

{{ /s }}

Context

{
    "s": "a<b"
}

Output

a&lt;b

html-escape-greater-than

{{ }} escapes > to > (covers the '>' branch of escapeHTML).

Template

{{ /s }}

Context

{
    "s": "a>b"
}

Output

a&gt;b

html-escape-double-quote

{{ }} escapes " to " (covers the '"' branch of escapeHTML).

Template

{{ /s }}

Context

{
    "s": "a\"b"
}

Output

a&quot;b

html-escape-single-quote

{{ }} escapes ' to ' (covers the '\'' branch of escapeHTML).

Template

{{ /s }}

Context

{
    "s": "a'b"
}

Output

a&#x27;b

html-escape-plain-chars-unchanged

Characters that are not HTML-special pass through unchanged (covers the else branch of escapeHTML).

Template

{{ /s }}

Context

{
    "s": "hello"
}

Output

hello

html-escape-empty-string

An empty string value renders as empty, exercising the isEmpty() fast-path in escapeHTML.

Template

{{ /s }}

Context

{
    "s": ""
}

Output


unescaped-interpolation-preserves-html-chars

{{{ }}} emits HTML-special characters verbatim; escapeHTML is not applied to UnescapedInterpolation segments.

Template

{{{ /s }}}

Context

{
    "s": "a&b<c>d\"e'f"
}

Output

a&b<c>d"e'f

Source fixture: render/html-escaping.json