Handlebars - the next generation
Language specification

ContentStatement

ContentStatements do not have a specific start and end-token. By default, all parts of the template that are not other statements are ContentStatements.

Content
ContentStatement ::
ContentCharacter ContentStatementopt
ContentCharacter ::
NonMustacheStart
\{{
\{{{
NonMustacheStart ::
SourceCharacter but not one of MustacheStart or MustacheStart[+Unescaped]
SourceCharacter ::
any Unicode code point

ContentStatements are copied verbatim to the output, except in the case described below.

04-content-statement/content.hb-spec.json
A simple template without mustaches
Template:
hello
world
Input / Output
Input
{}
Output
hello
world
AST
{
  "type": "Program",
  "body": [
    {
      "type": "ContentStatement",
      "value": "hello\nworld",
      "original": "hello\nworld",
      "loc": {
        "start": { "line": 1, "column": 0 },
        "end": { "line": 2, "column": 5 }
      }
    }
  ],
  "strip": {},
  "loc": {
    "start": { "line": 1, "column": 0 },
    "end": { "line": 2, "column": 5 }
  }
}

Escaped mustache statements

If an opening mustache tokens such as {{, {{{ or {{{{ is prefixed with a \, it does not start a mustache, but remains part of the ContentStatement. The backslash is not copied to the output.

04-content-statement/escaped-content.hb-spec.json
Escaped mustache expression
Template:
\{{abc}} \{{{cde}}}
Warning: The original Handlebars implementation has a deviating AST (which the author of this document considers to be wrong):
Input / Output
Input
{}
Output
{{abc}} {{{cde}}}
AST
{
  "type": "Program",
  "body": [
    {
      "type": "ContentStatement",
      "value": "{{abc}} {{{cde}}}",
      "original": "\\{{abc}} \\{{{cde}}}",
      "loc": {
        "start": { "line": 1, "column": 0 },
        "end": { "line": 1, "column": 19 }
      }
    }
  ],
  "strip": {},
  "loc": {
    "start": { "line": 1, "column": 0 },
    "end": { "line": 1, "column": 19 }
  }
}
Original AST
{
  "type": "Program",
  "body": [
    {
      "type": "ContentStatement",
      "value": "{{abc}} {{{cde}}}",
      "original": "{{abc}} {{{cde}}}",
      "loc": {
        "start": { "line": 1, "column": 1 },
        "end": { "line": 1, "column": 19 }
      }
    }
  ],
  "strip": {},
  "loc": {
    "start": { "line": 1, "column": 1 },
    "end": { "line": 1, "column": 19 }
  }
}