Skip to content

Struggling with ways to convert someting into Html. #3443

Open
@ctron

Description

@ctron

Problem

Steps To Reproduce
Steps to reproduce the behavior:

    #[test]
    fn test_to_html_to_children_comp_compiles() {
        use crate::prelude::*;

        struct Foo;

        impl ToHtml for Foo {
            fn to_html(&self) -> Html {
                html!()
            }
        }

        #[derive(PartialEq, Properties)]
        pub struct FooProps {
            pub children: Children,
        }

        #[function_component(Comp)]
        fn comp(props: &FooProps) -> Html {
            html!()
        }

        let _ = html!(<Comp>{Foo}</Comp>);
    }

Expected behavior

In the past it was possible to implement From<Foo> for Html to use something in the html macro, like this:

struct Foo;
html! (
 <SomeComponent>{ Foo }</SomeComponent>
)

Now there seem to be two new variants: ToHtml, and IntoPropValue<ChildrenRenderer<Vnode>>. However, it's not always clear when to use what and why sometimes ToHtml, doesn't work.

Environment:

  • Yew version: v0.21.0.
  • Rust version: 1.17.1

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions