mirror of https://github.com/sveltejs/svelte
commit
f5b78e406c
@ -0,0 +1,17 @@
|
||||
export default {
|
||||
data: {
|
||||
animals: [ 'alpaca', 'baboon', 'capybara' ],
|
||||
foo: 'something else'
|
||||
},
|
||||
html: 'before\n<p>alpaca</p><p>baboon</p><p>capybara</p>\nafter',
|
||||
test ( assert, component, target ) {
|
||||
component.set({ animals: [] });
|
||||
assert.htmlEqual( target.innerHTML, 'before\n<p>no animals, but rather something else</p>\nafter' );
|
||||
|
||||
component.set({ foo: 'something other' });
|
||||
assert.htmlEqual( target.innerHTML, 'before\n<p>no animals, but rather something other</p>\nafter' );
|
||||
|
||||
component.set({ animals: ['wombat'] });
|
||||
assert.htmlEqual( target.innerHTML, 'before\n<p>wombat</p>\nafter' );
|
||||
}
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
before
|
||||
{{#each animals as animal}}
|
||||
<p>{{animal}}</p>
|
||||
{{else}}
|
||||
<p>no animals, but rather {{foo}}</p>
|
||||
{{/each}}
|
||||
after
|
@ -0,0 +1,5 @@
|
||||
{{#each animals as animal}}
|
||||
<p>{{animal}}</p>
|
||||
{{else}}
|
||||
<p>no animals</p>
|
||||
{{/each}}
|
@ -0,0 +1,67 @@
|
||||
{
|
||||
"html": {
|
||||
"start": 0,
|
||||
"end": 84,
|
||||
"type": "Fragment",
|
||||
"children": [
|
||||
{
|
||||
"start": 0,
|
||||
"end": 84,
|
||||
"type": "EachBlock",
|
||||
"expression": {
|
||||
"start": 8,
|
||||
"end": 15,
|
||||
"type": "Identifier",
|
||||
"name": "animals"
|
||||
},
|
||||
"context": "animal",
|
||||
"children": [
|
||||
{
|
||||
"start": 29,
|
||||
"end": 46,
|
||||
"type": "Element",
|
||||
"name": "p",
|
||||
"attributes": [],
|
||||
"children": [
|
||||
{
|
||||
"start": 32,
|
||||
"end": 42,
|
||||
"type": "MustacheTag",
|
||||
"expression": {
|
||||
"start": 34,
|
||||
"end": 40,
|
||||
"type": "Identifier",
|
||||
"name": "animal"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"else": {
|
||||
"children": [
|
||||
{
|
||||
"attributes": [],
|
||||
"children": [
|
||||
{
|
||||
"data": "no animals",
|
||||
"end": 70,
|
||||
"start": 60,
|
||||
"type": "Text"
|
||||
}
|
||||
],
|
||||
"end": 74,
|
||||
"name": "p",
|
||||
"start": 57,
|
||||
"type": "Element"
|
||||
}
|
||||
],
|
||||
"end": 75,
|
||||
"start": 55,
|
||||
"type": "ElseBlock"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"css": null,
|
||||
"js": null
|
||||
}
|
Loading…
Reference in new issue