-
Notifications
You must be signed in to change notification settings - Fork 144
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
Allow for variable bindings (let statements) inside a template #57
Comments
Can you give me an example of how such a feature would be used? I've considered it in the past, but held back because I couldn't find a use case for it. Note that you can declare variables outside the |
because some situation e.g. @for n in 1..2 {}. |
@for n in somethings {
div {
@ { // here are any rust normal code.
let item = n.something.unwrap(); // here item in something is move out, so we cannot unwrap twise.
}
h1 { (item.name) }
a { (item.age) }
}
} |
Okay, that makes sense -- thanks. I have a feeling we need to go all the way to arbitrary Rust statements to solve your problem though. Maybe just a I'll need to think about this a bit more. |
but maybe this is powerful and smart. html! {
@ {
somefunction(); // I can run any rust code here.
}
} |
I have to say that I didn't need to do this so far, anything that should be run once can be run outside the macro, and the Note: I'm not trying to argue too hard against it, however it doesn't feel like something that is necessary. |
Implemented in 39602a0. The new @Sackery I don't want to allow arbitrary Rust statements within a template. If your view logic is complicated enough that you need a whole block for it, then that's a sign that it should be in a separate function altogether. |
For example:
@{ let a = bit.source.unwrap(); }
The text was updated successfully, but these errors were encountered: