Module
cli
Description
Currently {#each} only accepts arrays. Passing an object/map produces a render error: {#each} expects an array, got object.
For code generation and data-driven templates, iterating over key-value pairs of an object is a common need. Currently the only workaround is restructuring data into arrays on the Rust side before passing it to the template context, which adds boilerplate and couples template structure to Rust code.
A possible syntax following Svelte's pattern:
{#each Object.entries(data) as [key, value]}
{= key}: {= value}
{/each}
Or a dedicated destructuring form:
{#each myObject as { key, value }}
{= key}: {= value}
{/each}
This would allow templates to work directly with Value::Object data without requiring the Rust caller to convert maps to arrays of structs.
Module
cli
Description
Currently
{#each}only accepts arrays. Passing an object/map produces a render error:{#each} expects an array, got object.For code generation and data-driven templates, iterating over key-value pairs of an object is a common need. Currently the only workaround is restructuring data into arrays on the Rust side before passing it to the template context, which adds boilerplate and couples template structure to Rust code.
A possible syntax following Svelte's pattern:
Or a dedicated destructuring form:
This would allow templates to work directly with
Value::Objectdata without requiring the Rust caller to convert maps to arrays of structs.