Skip to content

Conformance Examples 0.1.0 — Render: literals-interpolation

string-literal-double-quoted

A double-quoted string literal renders its content unquoted, HTML-escaped.

Template

{{ "hi" }}

Output

hi

string-literal-single-quoted

A single-quoted string literal renders identically to the double-quoted form.

Template

{{ 'hi' }}

Output

hi

string-literal-html-escaped-in-double-mustache

HTML-special characters in a string literal are escaped under {{ }}.

Template

{{ "<b>raw</b>" }}

Output

&lt;b&gt;raw&lt;/b&gt;

string-literal-verbatim-in-triple-mustache

HTML-special characters in a string literal pass through verbatim under {{{ }}}.

Template

{{{ "<b>raw</b>" }}}

Output

<b>raw</b>

string-literal-with-embedded-quote

An escaped quote inside a double-quoted string literal is decoded by the parser before rendering, then HTML-escaped to its named entity.

Template

{{ "she said \"hi\"" }}

Output

she said &quot;hi&quot;

string-literal-empty

An empty-string literal renders as an empty string.

Template

[{{ "" }}]

Output

[]

integer-literal

An integer literal renders as its JSON form.

Template

{{ 42 }}

Output

42

negative-integer-literal

A negative integer literal includes the leading minus sign.

Template

{{ -7 }}

Output

-7

decimal-literal

A decimal literal renders with its fractional part.

Template

{{ 3.14 }}

Output

3.14

negative-decimal-literal

A negative decimal literal includes the leading minus sign.

Template

{{ -3.5 }}

Output

-3.5

zero-literal

The numeric literal 0 renders as "0" — it is not the same as the empty string.

Template

[{{ 0 }}]

Output

[0]

true-literal

The boolean literal true renders as the lowercase word "true".

Template

{{ true }}

Output

true

false-literal

The boolean literal false renders as the lowercase word "false".

Template

{{ false }}

Output

false

null-literal

The null literal renders as the literal text "null", matching the convention used for a null rendering context.

Template

{{ null }}

Output

null

literal-in-unescaped-triple-mustache

A numeric literal under {{{ }}} renders identically to {{ }} (numbers contain no HTML-special characters).

Template

{{{ 42 }}}

Output

42

literal-with-trim-open

Trim-open on a literal interpolation strips leading whitespace from the surrounding template text — the literal's own rendered value is untouched.

Template

  {{~ "  x" }}

Output

  x

literal-with-trim-close

Trim-close on a literal interpolation strips trailing whitespace from the surrounding template text — the literal's own rendered value is untouched.

Template

{{ "x  " ~}}  

Output

x  

literal-with-both-trim

Both trim variants applied at once strip leading and trailing whitespace from the surrounding template text — the literal's own rendered value is untouched.

Template

  {{~ "  x  " ~}}  

Output

  x  

string-literal-interior-whitespace-preserved

Whitespace inside a string literal is part of the value and is preserved verbatim — trim variants act on surrounding template text, not on the literal's content.

Template

[{{ "  spaced  " }}]

Output

[  spaced  ]

literal-alongside-identifier

A literal interpolation and an identifier interpolation coexist in the same template.

Template

{{ "hello, " }}{{ name }}

Context

{
    "name": "Alice"
}

Output

hello, Alice

Source fixture: render/literals-interpolation.json