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
hello
world
{}
hello
world
{
"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
\{{abc}} \{{{cde}}}
Warning: The original Handlebars implementation has a deviating AST
(which the author of this document considers to be wrong):
{}
{{abc}} {{{cde}}}
{
"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 }
}
}
{
"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 }
}
}