This is unreleased documentation for Yew Next version.
For up-to-date documentation, see the latest version on docs.rs.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::html::ImplicitClone;
use crate::AttrValue;

/// A raw HTML string to be used in VDOM.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VRaw {
    pub html: AttrValue,
}

impl ImplicitClone for VRaw {}

impl From<AttrValue> for VRaw {
    fn from(html: AttrValue) -> Self {
        Self { html }
    }
}

#[cfg(feature = "ssr")]
mod feat_ssr {
    use std::fmt::Write;

    use super::*;
    use crate::html::AnyScope;
    use crate::platform::fmt::BufWriter;
    use crate::virtual_dom::Collectable;

    impl VRaw {
        pub(crate) async fn render_into_stream(
            &self,
            w: &mut BufWriter,
            _parent_scope: &AnyScope,
            hydratable: bool,
        ) {
            let collectable = Collectable::Raw;

            if hydratable {
                collectable.write_open_tag(w);
            }

            let _ = w.write_str(self.html.as_ref());

            if hydratable {
                collectable.write_close_tag(w);
            }
        }
    }
}