File tree 4 files changed +17
-12
lines changed
parser/samples/each-block-keyed
runtime/samples/each-block-keyed
4 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -274,8 +274,8 @@ export default function mustache(parser: Parser) {
274
274
parser . allowWhitespace ( ) ;
275
275
}
276
276
277
- if ( parser . eat ( 'key ' ) ) {
278
- parser . requireWhitespace ( ) ;
277
+ if ( parser . eat ( '( ' ) ) {
278
+ parser . allowWhitespace ( ) ;
279
279
280
280
const expression = readExpression ( parser ) ;
281
281
@@ -292,6 +292,8 @@ export default function mustache(parser: Parser) {
292
292
293
293
block . key = expression . property . name ;
294
294
parser . allowWhitespace ( ) ;
295
+ parser . eat ( ')' , true ) ;
296
+ parser . allowWhitespace ( ) ;
295
297
} else if ( parser . eat ( '@' ) ) {
296
298
block . key = parser . readIdentifier ( ) ;
297
299
if ( ! block . key ) parser . error ( `Expected name` ) ;
Original file line number Diff line number Diff line change 1
- {#each todos as todo key todo.id}
1
+ {#each todos as todo ( todo.id) }
2
2
< p > {todo}</ p >
3
3
{/each}
Original file line number Diff line number Diff line change 1
1
{
2
- "hash" : " 3sm0ec " ,
2
+ "hash" : " 1x6az5m " ,
3
3
"html" : {
4
4
"start" : 0 ,
5
- "end" : 56 ,
5
+ "end" : 54 ,
6
6
"type" : " Fragment" ,
7
7
"children" : [
8
8
{
9
9
"start" : 0 ,
10
- "end" : 56 ,
10
+ "end" : 54 ,
11
11
"type" : " EachBlock" ,
12
12
"expression" : {
13
13
"type" : " Identifier" ,
17
17
},
18
18
"children" : [
19
19
{
20
- "start" : 35 ,
21
- "end" : 48 ,
20
+ "start" : 33 ,
21
+ "end" : 46 ,
22
22
"type" : " Element" ,
23
23
"name" : " p" ,
24
24
"attributes" : [],
25
25
"children" : [
26
26
{
27
- "start" : 38 ,
28
- "end" : 44 ,
27
+ "start" : 36 ,
28
+ "end" : 42 ,
29
29
"type" : " MustacheTag" ,
30
30
"expression" : {
31
31
"type" : " Identifier" ,
32
- "start" : 39 ,
33
- "end" : 43 ,
32
+ "start" : 37 ,
33
+ "end" : 41 ,
34
34
"name" : " todo"
35
35
}
36
36
}
Original file line number Diff line number Diff line change
1
+ {#each todos as todo, i (todo.id)}
2
+ < p > {i+1}: {todo.description}</ p >
3
+ {/each}
You can’t perform that action at this time.
0 commit comments