pub struct HtmlBody<'a> { /* private fields */ }
Implementations§
Source§impl<'a> HtmlBody<'a>
impl<'a> HtmlBody<'a>
Sourcepub fn builder() -> HtmlBody<'a>
pub fn builder() -> HtmlBody<'a>
Examples found in repository?
examples/getting_started.rs (line 24)
6fn main() {
7 let title = Title::builder().append_child(TextContent::text("It works!"));
8 let style = HtmlStyle::new("body { color: #000000; }");
9 let script1 = HtmlScript::new(
10 format!(
11 r#"console.log("Hello from file {} at line {}")"#,
12 file!(),
13 line!(),
14 )
15 .as_str(),
16 );
17
18 let div = Div::builder().attr("class", "light-theme").append_child(
19 P::builder()
20 .attr("class", "light-theme")
21 .append_child(TextContent::text("It Works!")),
22 );
23
24 let body = HtmlBody::builder()
25 .set_attr("lang", "en")
26 .script(script1)
27 .append_child(div);
28
29 let script2 = HtmlScript::new(
30 format!(
31 r#"console.log("Hello from file {} at line {}")"#,
32 file!(),
33 line!(),
34 )
35 .as_str(),
36 );
37 let html = Html::builder()
38 .head_item(title)
39 .add_style(style)
40 .add_script(script2)
41 .body(body);
42
43 #[cfg(feature = "debug")]
44 dbg!(&html);
45
46 println!("{html}");
47}
Sourcepub fn script(self, script: HtmlScript<'a>) -> HtmlBody<'a>
pub fn script(self, script: HtmlScript<'a>) -> HtmlBody<'a>
Examples found in repository?
examples/getting_started.rs (line 26)
6fn main() {
7 let title = Title::builder().append_child(TextContent::text("It works!"));
8 let style = HtmlStyle::new("body { color: #000000; }");
9 let script1 = HtmlScript::new(
10 format!(
11 r#"console.log("Hello from file {} at line {}")"#,
12 file!(),
13 line!(),
14 )
15 .as_str(),
16 );
17
18 let div = Div::builder().attr("class", "light-theme").append_child(
19 P::builder()
20 .attr("class", "light-theme")
21 .append_child(TextContent::text("It Works!")),
22 );
23
24 let body = HtmlBody::builder()
25 .set_attr("lang", "en")
26 .script(script1)
27 .append_child(div);
28
29 let script2 = HtmlScript::new(
30 format!(
31 r#"console.log("Hello from file {} at line {}")"#,
32 file!(),
33 line!(),
34 )
35 .as_str(),
36 );
37 let html = Html::builder()
38 .head_item(title)
39 .add_style(style)
40 .add_script(script2)
41 .body(body);
42
43 #[cfg(feature = "debug")]
44 dbg!(&html);
45
46 println!("{html}");
47}
Sourcepub fn append_child(self, element: HtmlElement<'a>) -> HtmlBody<'a>
pub fn append_child(self, element: HtmlElement<'a>) -> HtmlBody<'a>
Examples found in repository?
examples/getting_started.rs (line 27)
6fn main() {
7 let title = Title::builder().append_child(TextContent::text("It works!"));
8 let style = HtmlStyle::new("body { color: #000000; }");
9 let script1 = HtmlScript::new(
10 format!(
11 r#"console.log("Hello from file {} at line {}")"#,
12 file!(),
13 line!(),
14 )
15 .as_str(),
16 );
17
18 let div = Div::builder().attr("class", "light-theme").append_child(
19 P::builder()
20 .attr("class", "light-theme")
21 .append_child(TextContent::text("It Works!")),
22 );
23
24 let body = HtmlBody::builder()
25 .set_attr("lang", "en")
26 .script(script1)
27 .append_child(div);
28
29 let script2 = HtmlScript::new(
30 format!(
31 r#"console.log("Hello from file {} at line {}")"#,
32 file!(),
33 line!(),
34 )
35 .as_str(),
36 );
37 let html = Html::builder()
38 .head_item(title)
39 .add_style(style)
40 .add_script(script2)
41 .body(body);
42
43 #[cfg(feature = "debug")]
44 dbg!(&html);
45
46 println!("{html}");
47}
Sourcepub fn set_attr<K: AsRef<str>, V: AsRef<str>>(
self,
key: K,
value: V,
) -> HtmlBody<'a>
pub fn set_attr<K: AsRef<str>, V: AsRef<str>>( self, key: K, value: V, ) -> HtmlBody<'a>
Examples found in repository?
examples/getting_started.rs (line 25)
6fn main() {
7 let title = Title::builder().append_child(TextContent::text("It works!"));
8 let style = HtmlStyle::new("body { color: #000000; }");
9 let script1 = HtmlScript::new(
10 format!(
11 r#"console.log("Hello from file {} at line {}")"#,
12 file!(),
13 line!(),
14 )
15 .as_str(),
16 );
17
18 let div = Div::builder().attr("class", "light-theme").append_child(
19 P::builder()
20 .attr("class", "light-theme")
21 .append_child(TextContent::text("It Works!")),
22 );
23
24 let body = HtmlBody::builder()
25 .set_attr("lang", "en")
26 .script(script1)
27 .append_child(div);
28
29 let script2 = HtmlScript::new(
30 format!(
31 r#"console.log("Hello from file {} at line {}")"#,
32 file!(),
33 line!(),
34 )
35 .as_str(),
36 );
37 let html = Html::builder()
38 .head_item(title)
39 .add_style(style)
40 .add_script(script2)
41 .body(body);
42
43 #[cfg(feature = "debug")]
44 dbg!(&html);
45
46 println!("{html}");
47}
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for HtmlBody<'a>
impl<'a> !RefUnwindSafe for HtmlBody<'a>
impl<'a> !Send for HtmlBody<'a>
impl<'a> !Sync for HtmlBody<'a>
impl<'a> Unpin for HtmlBody<'a>
impl<'a> !UnwindSafe for HtmlBody<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more