-
-
Notifications
You must be signed in to change notification settings - Fork 656
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
Add fixed size array rendering #3174
Conversation
tachys/src/view/iterators.rs
Outdated
} | ||
|
||
fn html_len(&self) -> usize { | ||
self.iter().map(RenderHtml::html_len).sum::<usize>() + 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I removed 1 from the constant compared to the Vec implementation. I did this guessing that the placeholder was counted in. But I have no idea what the constant is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 3 was the length of the comment node <!>
:-) So this can just be 0, but it's also just an estimate/heuristic
tachys/src/view/iterators.rs
Outdated
for child in self.into_iter() { | ||
child.to_html_with_buf(buf, position, escape, mark_branches); | ||
} | ||
buf.push_str("<!>"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inserting the placeholder here will cause an issue, as it's not used during hydration (so children after this will hydrate incorrectly because there's an extra node
tachys/src/view/iterators.rs
Outdated
mark_branches, | ||
); | ||
} | ||
buf.push_sync("<!>"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(See above)
Thanks so much! This looks great over all, I added a couple comments about the placeholders for information, but I just added a quick commit to fix it, so I don't think there's any action needed on your part. |
Hello, I was using fixed size array and the render method is not implemented on them.
I find it weird that it's implemented on Vec but not arrays. So I wrote a quick implementation.
Is there a reason it's not implemented ?
This allow to pass the array directly to the view method without converting it into a vec.
It's mostly a copy of the Vec implementation with minor adjustments :
I used the
<[]>::map
function most of the time.The only exception is for the
future::join_all
that takes and return an iterator.For the
Render::rebuild
method I don't know if there is a smart way of handling it. So I just wrote a naive implementation.