1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
pub use cratePage;
/// A reusable UI component.
///
/// Implement this trait on any struct to make it renderable inside
/// [`view!`](macro@crate::view), [`page!`](macro@crate::page), or other
/// components. The [`to_render`](Component::to_render) method receives a
/// mutable reference to the current [`Page`] so that child components can
/// inject CSS or `<head>` elements.
///
/// # Example
///
/// ```rust,no_run
/// use tidos::{view, Component, Page};
///
/// pub struct Alert {
/// pub message: String,
/// }
///
/// impl Component for Alert {
/// fn to_render(&self, page: &mut Page) -> String {
/// view! {
/// <div class="alert">
/// <p>{&self.message}</p>
/// </div>
/// }
/// }
/// }
/// ```