Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add array destructuring for each contexts #889

Merged
merged 3 commits into from
Oct 17, 2017

Conversation

jacobmischka
Copy link
Contributor

@jacobmischka jacobmischka commented Oct 10, 2017

Example repo, ran with svelte npm linked to branch as indicated in readme.

Note this does not do object destructuring, just array destructuring.

Input:

<div>
	{{#each Object.entries(map) as [key, value], i}}
		<h2>{{ key }}: {{ i }}</h2>
		{{#each Object.entries(value) as [subkey, subvalue], j}}
			<p>
				{{subkey}}: {{subvalue}}
			</p>
		{{/each}}
	{{/each}}
</div>

<script>
export default {
	data() {
		return {
			map: {
				key: {
					subkey: 'subval',
					subkey2: 'subval2'
				},
				anotherKey: {
					anotherSubkey: 'anotherSubval',
					anotherSubkey2: 'anotherSubval2'
				}
			}
		};
	}
};
</script>

Result:
screenshot from 2017-10-09 20-37-46

Fixes #888

@jacobmischka
Copy link
Contributor Author

Oops hang on I forgot some tests and missed some ssr bugs, will reopen when fixed

@jacobmischka jacobmischka reopened this Oct 10, 2017
@jacobmischka
Copy link
Contributor Author

Okay looks like CI doesn't like Object.entries in the test, fair enough.

@Rich-Harris Rich-Harris merged commit c394aa7 into sveltejs:master Oct 17, 2017
@Rich-Harris
Copy link
Member

Nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants