-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Using html[_nested]! { ... }
as a prop value produces an obscure error
#2267
Comments
If html! {
<Page sidebar={{
html_nested! {
<PageSideBar />
}
}} />
} I have no idea what's happening here. This needs further investigation |
will try to fix this |
@kawadakk you followed outdated documentation, what you referred to was old behavior before and including 0.18. here is the relevant documentation for 0.19 and it does expect extra braces same as the next/master version. @hamza1311 the behavior change isn't introduced by me, but by dates before #2014. And it seems indeed unnatural to add these many pairs of braces though. Do you think this issue can be closed? |
The shown example was taken from a commit after #1939 (where the brace requirement for v0.19 was introduced) and before #2014 (documentation testing was introduced). #2014 added an extra pair of braces to make the example code compile. Afaik it's never made clear which part was at fault in this change of #2014. I think one of the following things describes what happened:
In any case, the error message is still incorrect because |
To me, let foo = html_nested! { ... };
html! {
<Something prop={foo} />
} |
You guys are right, will investigate and see what I can do then |
I found the culprit, when parsing props of the form I had the creative idea of "eager expanding" to peek if the passed in macro will expand into an expression but that seems not possible in Rust after I've discussed the idea with other people. I think considering this edge case and making the prop parser accept either Expr or Macro is the right way to go. Does anybody have other suggestions? |
convert macro invocation Item statements to Exprs
* fix: macro invocations in props #2267 convert macro invocation Item statements to Exprs * remove now useless braces in docs
Problem
Using
html! { ... }
orhtml_nested! { ... }
as a prop value inhtml!
produces an obscure error.Steps To Reproduce
html! { ... }
expression in which there's anotherhtml_nested! { ... }
directly inside a prop value. An example based on the pre-Add testing for website code blocks #2014 documentation:html!
doesn't treathtml_nested! { ... }
as an expression:Expected behavior
Successful compilation or a helpful error messsage
Environment:
Questionnaire
The text was updated successfully, but these errors were encountered: