@ -174,13 +174,30 @@ function open(parser) {
if ( parser . eat ( '(' ) ) {
if ( parser . eat ( '(' ) ) {
parser . allow _whitespace ( ) ;
parser . allow _whitespace ( ) ;
key = read _expression ( parser );
key = read _expression ( parser , '(' );
parser . allow _whitespace ( ) ;
parser . allow _whitespace ( ) ;
parser . eat ( ')' , true ) ;
parser . eat ( ')' , true ) ;
parser . allow _whitespace ( ) ;
parser . allow _whitespace ( ) ;
}
}
const matches = parser . eat ( '}' , true , false ) ;
if ( ! matches ) {
// Parser may have read the `as` as part of the expression (e.g. in `{#each foo. as x}`)
if ( parser . template . slice ( parser . index - 4 , parser . index ) === ' as ' ) {
const prev _index = parser . index ;
context = read _pattern ( parser ) ;
parser . eat ( '}' , true ) ;
parser . eat ( '}' , true ) ;
expression = {
type : 'Identifier' ,
name : '' ,
start : expression . start ,
end : prev _index - 4
} ;
} else {
parser . eat ( '}' , true ) ; // rerun to produce the parser error
}
}
/** @type {AST.EachBlock} */
/** @type {AST.EachBlock} */
const block = parser . append ( {
const block = parser . append ( {
@ -246,7 +263,39 @@ function open(parser) {
parser . fragments . push ( block . pending ) ;
parser . fragments . push ( block . pending ) ;
}
}
const matches = parser . eat ( '}' , true , false ) ;
// Parser may have read the `then/catch` as part of the expression (e.g. in `{#await foo. then x}`)
if ( ! matches ) {
if ( parser . template . slice ( parser . index - 6 , parser . index ) === ' then ' ) {
const prev _index = parser . index ;
block . value = read _pattern ( parser ) ;
parser . eat ( '}' , true ) ;
parser . eat ( '}' , true ) ;
block . expression = {
type : 'Identifier' ,
name : '' ,
start : expression . start ,
end : prev _index - 6
} ;
block . then = block . pending ;
block . pending = null ;
} else if ( parser . template . slice ( parser . index - 7 , parser . index ) === ' catch ' ) {
const prev _index = parser . index ;
block . error = read _pattern ( parser ) ;
parser . eat ( '}' , true ) ;
block . expression = {
type : 'Identifier' ,
name : '' ,
start : expression . start ,
end : prev _index - 7
} ;
block . catch = block . pending ;
block . pending = null ;
} else {
parser . eat ( '}' , true ) ; // rerun to produce the parser error
}
}
parser . stack . push ( block ) ;
parser . stack . push ( block ) ;
return ;
return ;