Add transformer String to VNode#1626
Closed
yozhgoor wants to merge 4 commits into
Closed
Conversation
add a transformer to transform string into VNode
Member
|
This, to me, feels too implicit given that a more explicit version already exists: html! {
<Model label=html!("Cooperative") />
}If you think that's too verbose for your use case you can create a dedicated type and implement the transformation for that. struct MyWrapper(Html);
impl Transformer<Html, MyWrapper> for VComp {}
impl Transformer<&'_ str, MyWrapper> for VComp {}
struct Props {
label: MyWrapper,
}
html! {
<Model label=html! { <strong>{ "works!" }</strong> } />
<Model label="also works" />
} |
Contributor
Contributor
|
(The wrapper thingy is a no go solution imo. It would introduce some specific magic to a library of yew, it will feel counter intuitive to the user) |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I contribute to yewprint. I use VNode as a type of some props and I want to allow the user to pass a component instead of just a String.
Example: cecton/yewprint@d2f5ee8
In this example, I have try to use a VNode as a label and now I need to replace all the labels in my code with
label=html!("Animate")and that in 31 places.Checklist
cargo make pr-flow