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