10000 Support tags with dynamic/variable children · Issue #230 · anp/moxie · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Support tags with dynamic/variable children #230
Open
@anp

Description

@anp

In the dom-hacking example, we ensure we can add children in a loop (which also works for a conditional):

let mut root = div();
root = root.child(mox! { <div>{% "hello world from moxie! ({})", &count }</div> });
root = root.child(mox! {
<button type="button" class="pl-kos">{move |_| set_count.update(|c| Some(c + 1))}>
"increment"
</button>
});
for t in &["first", "second", "third"] {
root = root.child(mox! { <div>{% "{}", t }</div> });
}
root.build()

It would be nice to be able to write the whole example as a single mox invocation, maybe something like:

mox! {
    <div>
        <div>{% "hello world from moxie! ({})", &count }</div>
        <button type="button"  |_| set_count.update(|c| Some(c + 1))}>
            "increment"
        </button>
        |mut root: Div| -> Div {
            for t in &["first", "second", "third"] {
                root = root.child(mox! { <div>{% "{}", t }</div> });
            }
            root
        }
    </div>
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    moxRelated to our mockery of XML

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0