Skip to content

[feat] Support object/map iteration in {#each} #7

@thwbh

Description

@thwbh

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions