This is unreleased documentation for Yew Next version.
For up-to-date documentation, see the latest version on docs.rs.

yew/virtual_dom/
vraw.rs

1use crate::html::ImplicitClone;
2use crate::AttrValue;
3
4/// A raw HTML string to be used in VDOM.
5#[derive(Clone, Debug, PartialEq, Eq)]
6pub struct VRaw {
7    pub html: AttrValue,
8}
9
10impl ImplicitClone for VRaw {}
11
12impl From<AttrValue> for VRaw {
13    fn from(html: AttrValue) -> Self {
14        Self { html }
15    }
16}
17
18#[cfg(feature = "ssr")]
19mod feat_ssr {
20    use std::fmt::Write;
21
22    use super::*;
23    use crate::html::AnyScope;
24    use crate::platform::fmt::BufWriter;
25    use crate::virtual_dom::Collectable;
26
27    impl VRaw {
28        pub(crate) async fn render_into_stream(
29            &self,
30            w: &mut BufWriter,
31            _parent_scope: &AnyScope,
32            hydratable: bool,
33        ) {
34            let collectable = Collectable::Raw;
35
36            if hydratable {
37                collectable.write_open_tag(w);
38            }
39
40            let _ = w.write_str(self.html.as_ref());
41
42            if hydratable {
43                collectable.write_close_tag(w);
44            }
45        }
46    }
47}