Handlebars - the next generation
Language specification

Full Grammar

Warning: This grammar is still work in progress. We aim to declare the whole Handlebars grammar here, but most features are still missing. However, feedback is always welcome. Please head over to Github to open your first issue. If you think something is wrong or could be better.

Program ::
ContentStatement
MustacheStatement
MustacheStatement[+Unescaped]
ContentStatement ::
ContentCharacter ContentStatementopt
ContentCharacter ::
NonMustacheStart
\{{
\{{{
NonMustacheStart ::
SourceCharacter but not one of MustacheStart or MustacheStart[+Unescaped]
SourceCharacter ::
any Unicode code point
MustacheStatement[Unescaped] ::
MustacheStart[?Unescaped] MustacheContents MustacheEnd[?Unescaped]
MustacheStart[Unescaped] ::
[+Unescaped]{{{
[~Unescaped]{{
MustacheEnd[Unescaped] ::
[+Unescaped]}}}
[~Unescaped]}}
MustacheContents ::
WhitespaceControlopt Whitespaceopt PathExpression MustacheParametersopt Whitespaceopt WhitespaceControlopt
WhitespaceControl :: ~
Whitespace ::
WhitespaceChar Whitespaceopt
WhitespaceChar :: one of
<SPACE> <TAB> <LF> <CR>
PathExpression ::
Id PathExpressionTailopt
PathExpressionTail ::
. PathExpression
/ PathExpression
Id ::
IdCharacter Idopt
IdCharacter ::
SourceCharacter but not one of NonIdCharacter or Whitespace
NonIdCharacter :: one of
! " # % & ' ( ) * + , . / ; < = > @ [ \ ] ^ ` { | } ~
MustacheParameters ::
Whitespace MustacheParameter MustacheParametersopt
MustacheParameter ::
Literal
PathExpression
SubExpression
Literal ::
StringLiteral
NumberLiteral
BooleanLiteral
StringLiteral ::
" AnythingExceptDoubleQuote "
' AnythingExceptSingleQuote '
AnythingExceptDoubleQuote ::
SourceCharacter but not "
AnythingExceptSingleQuote ::
SourceCharacter but not '
NumberLiteral ::
Minusopt Digits Fractionopt
Minus ::
-
Digits ::
Digit Digits
Digit :: one of
0 1 2 3 4 5 6 7 8 9
Fraction ::
. Digits
BooleanLiteral :: one of
true false
SubExpression ::
( Whitespaceopt PathExpression MustacheParametersopt Whitespaceopt )