pub struct Aside { /* private fields */ }Expand description
Builder for <aside> elements.
Represents content tangentially related to the surrounding content, such as sidebars, pull quotes, or advertising.
§Examples
use html_generator::elements::{Aside, SemanticElement};
let html = Aside::new()
.class("related")
.child("<p>See also</p>")
.build();
assert!(html.contains("<aside"));
assert!(html.contains(r#"class="related""#));Implementations§
Source§impl Aside
impl Aside
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new builder with default values.
§Examples
use html_generator::elements::{Article, SemanticElement};
let html = Article::new().build();
assert!(html.contains("<article"));Sourcepub fn id(self, id: &str) -> Self
pub fn id(self, id: &str) -> Self
Sets the id attribute.
§Examples
use html_generator::elements::{Article, SemanticElement};
let html = Article::new().id("post-1").build();
assert!(html.contains(r#"id="post-1""#));Sourcepub fn class(self, class: &str) -> Self
pub fn class(self, class: &str) -> Self
Sets the class attribute.
§Examples
use html_generator::elements::{Article, SemanticElement};
let html = Article::new().class("post").build();
assert!(html.contains(r#"class="post""#));Sourcepub fn aria_label(self, label: &str) -> Self
pub fn aria_label(self, label: &str) -> Self
Sets the aria-label attribute.
§Examples
use html_generator::elements::{Article, SemanticElement};
let html = Article::new().aria_label("Latest post").build();
assert!(html.contains(r#"aria-label="Latest post""#));Sourcepub fn aria_labelledby(self, id: &str) -> Self
pub fn aria_labelledby(self, id: &str) -> Self
Sets the aria-labelledby attribute.
§Examples
use html_generator::elements::{Article, SemanticElement};
let html = Article::new().aria_labelledby("title-1").build();
assert!(html.contains(r#"aria-labelledby="title-1""#));Sourcepub fn attr(self, key: &str, value: &str) -> Self
pub fn attr(self, key: &str, value: &str) -> Self
Adds a custom attribute.
§Examples
use html_generator::elements::{Article, SemanticElement};
let html = Article::new().attr("data-id", "42").build();
assert!(html.contains(r#"data-id="42""#));Sourcepub fn child(self, html: &str) -> Self
pub fn child(self, html: &str) -> Self
Appends child HTML content.
§Examples
use html_generator::elements::{Article, SemanticElement};
let html = Article::new().child("<p>Body</p>").build();
assert!(html.contains("<p>Body</p>"));Trait Implementations§
Auto Trait Implementations§
impl Freeze for Aside
impl RefUnwindSafe for Aside
impl Send for Aside
impl Sync for Aside
impl Unpin for Aside
impl UnsafeUnpin for Aside
impl UnwindSafe for Aside
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