#[derive(Renderable)]
{
// Attributes available to this derive:
#[maud]
#[rsx]
#[attribute]
}
Available on crate feature
alloc only.Expand description
Derive Renderable for a type.
§Examples
§maud!
use hypertext::prelude::*;
#[derive(Renderable)]
#[maud(span { "My name is " (self.name) "!" })]
pub struct Person {
name: String,
}
assert_eq!(
maud! { div { (Person { name: "Alice".into() }) } }
.render()
.as_inner(),
"<div><span>My name is Alice!</span></div>"
);§rsx!
use hypertext::prelude::*;
#[derive(Renderable)]
#[rsx(
<span>"My name is " (self.name) "!"</span>
)]
pub struct Person {
name: String,
}
assert_eq!(
rsx! { <div> (Person { name: "Alice".into() }) </div> }
.render()
.as_inner(),
"<div><span>My name is Alice!</span></div>"
);§attribute!
use hypertext::prelude::*;
#[derive(Renderable)]
#[attribute((self.x) "," (self.y))]
pub struct Coordinates {
x: i32,
y: i32,
}
assert_eq!(
maud! { div title=(Coordinates { x: 10, y: 20 }) { "Location" } }
.render()
.as_inner(),
r#"<div title="10,20">Location</div>"#
);