[][src]Trait render::Renderable

pub trait Renderable: Debug + Sized {
    fn render(self) -> String;
}

A renderable component

Required methods

fn render(self) -> String

Render the component to the HTML representation.

Mostly done using the html! macro to generate strings by composing tags.

A simple implementation:

#[derive(Debug)]
struct Header<'t> { title: &'t str }

impl<'t> Renderable for Header<'t> {
    fn render(self) -> String {
        html! {
            <h1>{self.title}</h1>
        }
    }
}

// Then you can use it with

let rendered_html = html! {
    <Header title={"Hello world!"} />
};

Children

children is a special field that will be populated with other Renderable if any children was provided, by both the html! and the rsx! macros.

Loading content...

Implementations on Foreign Types

impl Renderable for ()[src]

Renders an empty string

impl<A: Renderable, B: Renderable> Renderable for (A, B)[src]

Renders A and then B

impl<A: Renderable, B: Renderable, C: Renderable> Renderable for (A, B, C)[src]

Renders A, B, and then C

impl<A: Renderable, B: Renderable, C: Renderable, D: Renderable> Renderable for (A, B, C, D)[src]

Renders A, B, C and then D

impl<T: Renderable> Renderable for Option<T>[src]

Renders the T or an empty string

impl<O: Renderable, E: Renderable> Renderable for Result<O, E>[src]

Renders O or E

impl Renderable for String[src]

Renders an escaped-html string

impl<'_> Renderable for &'_ str[src]

Renders an escaped-html string

Loading content...

Implementors

impl Renderable for HTML5Doctype[src]

impl<'a, T: Renderable> Renderable for SimpleElement<'a, T>[src]

impl<'s> Renderable for Raw<'s>[src]

A raw (unencoded) html string

impl<T: Renderable> Renderable for Fragment<T>[src]

Loading content...