parse @id for keyed each blocks (#81)

pull/209/head
Rich-Harris 8 years ago
parent 4332310550
commit 8340583fa1

@ -171,6 +171,12 @@ export default function mustache ( parser ) {
if ( !block.index ) parser.error( `Expected name` );
parser.allowWhitespace();
}
if ( parser.eat( '@' ) ) {
block.key = parser.read( validIdentifier );
if ( !block.key ) parser.error( `Expected name` );
parser.allowWhitespace();
}
}
parser.eat( '}}', true );

@ -0,0 +1,3 @@
{{#each todos as todo @id}}
<p>{{todo}}</p>
{{/each}}

@ -0,0 +1,46 @@
{
"html": {
"start": 0,
"end": 54,
"type": "Fragment",
"children": [
{
"start": 0,
"end": 54,
"type": "EachBlock",
"expression": {
"start": 8,
"end": 13,
"type": "Identifier",
"name": "todos"
},
"context": "todo",
"key": "id",
"children": [
{
"start": 29,
"end": 44,
"type": "Element",
"name": "p",
"attributes": [],
"children": [
{
"start": 32,
"end": 40,
"type": "MustacheTag",
"expression": {
"start": 34,
"end": 38,
"type": "Identifier",
"name": "todo"
}
}
]
}
]
}
]
},
"css": null,
"js": null
}
Loading…
Cancel
Save