Struct Html

Source
pub struct Html<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Html<'a>

Source

pub fn builder() -> Html<'a>

Examples found in repository?
examples/getting_started.rs (line 37)
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}
Source

pub fn head_item(self, elem: HtmlElement<'a>) -> Html<'a>

Examples found in repository?
examples/getting_started.rs (line 38)
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}
Source

pub fn add_style(self, style: HtmlStyle<'a>) -> Html<'a>

Examples found in repository?
examples/getting_started.rs (line 39)
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}
Source

pub fn add_script(self, script: HtmlScript<'a>) -> Html<'a>

Examples found in repository?
examples/getting_started.rs (line 40)
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}
Source

pub fn body(self, body: HtmlBody<'a>) -> Html<'a>

Examples found in repository?
examples/getting_started.rs (line 41)
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}
Source

pub fn is_complete(&self) -> bool

Trait Implementations§

Source§

impl<'a> Debug for Html<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Html<'a>

Source§

fn default() -> Html<'a>

Returns the “default value” for a type. Read more
Source§

impl Display for Html<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Html<'a>

§

impl<'a> !RefUnwindSafe for Html<'a>

§

impl<'a> !Send for Html<'a>

§

impl<'a> !Sync for Html<'a>

§

impl<'a> Unpin for Html<'a>

§

impl<'a> !UnwindSafe for Html<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.