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

Controllable boolean attributes #237

Closed
simonchatts opened this issue Sep 11, 2021 · 0 comments · Fixed by #239
Closed

Controllable boolean attributes #237

simonchatts opened this issue Sep 11, 2021 · 0 comments · Fixed by #239
Assignees
Labels
A-view Area: view! macro C-enhancement Category: new feature or improvement to existing feature

Comments

@simonchatts
Copy link

For boolean attributes such as hidden or checked, it would be handy to be able to control the presence or absence via a boolean expression.

One way to do this is what Yew does: require a boolean value in the template! (as is required today) but include the attribute if-and-only-if the value is true.

As an example, this would shrink code like this:

    template! {
        (if *is_empty.get() {
            template! {
                button(type="submit", class="btn btn-outline-primary", disabled=true) { "Submit" }
            }
        } else {
            template! {
                button(type="submit", class="btn btn-outline-primary") { "Submit" }
            }
        })
    }

down to this:

    template! {
        button(type="submit", class="btn btn-outline-primary", disabled=*is_empty.get()) { "Submit" }
    }
@simonchatts simonchatts added the C-enhancement Category: new feature or improvement to existing feature label Sep 11, 2021
@lukechu10 lukechu10 added the A-view Area: view! macro label Sep 12, 2021
@lukechu10 lukechu10 self-assigned this Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-view Area: view! macro C-enhancement Category: new feature or improvement to existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants