kbrsh / moon

🌙 The minimal & fast library for functional user interfaces
https://moonjs.org
MIT License
6k stars 200 forks source link

Component Syntax for "For" does not work #241

Closed Rukenshia closed 5 years ago

Rukenshia commented 6 years ago

Hi,

just found out that the syntax described in the docs does not work:

<For={$item,$index in items}>
    <p>{$item}</p>
    <p>{$index}</p>
</For>

Moon({
    root: "#root",
    items: ["foo", "bar", "baz"]
});

results in: image

kbrsh commented 5 years ago

Not sure what is causing this issue. I'll look into it and am planning to update the alternate syntax for <For>.

w33zy commented 5 years ago

I have just started using Moon I am also getting this error...

kbrsh commented 5 years ago

This now works with the rewrite:

Moon({
    root: "#root",
    items: ["foo", "bar", "baz"],
    view: `
        <for={$item, $index} of={items}>
            <p>{$item} {$index}</p>
        </for>
    `
});