pub struct MetaTagsBuilder { /* private fields */ }Expand description
Builder for constructing meta tags.
§Examples
use html_generator::seo::MetaTagsBuilder;
let tags = MetaTagsBuilder::new()
.with_title("My Page")
.with_description("An example page")
.build()
.unwrap();
assert!(tags.contains(r#"name="title""#));
assert!(tags.contains(r#"name="description""#));Implementations§
Source§impl MetaTagsBuilder
impl MetaTagsBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new MetaTagsBuilder with default values.
§Examples
use html_generator::seo::MetaTagsBuilder;
let _ = MetaTagsBuilder::new();Sourcepub fn with_title(self, title: impl Into<String>) -> Self
pub fn with_title(self, title: impl Into<String>) -> Self
Sets the title for the meta tags.
§Examples
use html_generator::seo::MetaTagsBuilder;
let tags = MetaTagsBuilder::new()
.with_title("Home")
.with_description("welcome")
.build()
.unwrap();
assert!(tags.contains(r#"content="Home""#));Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Sets the description for the meta tags.
§Examples
use html_generator::seo::MetaTagsBuilder;
let tags = MetaTagsBuilder::new()
.with_title("t")
.with_description("an example description")
.build()
.unwrap();
assert!(tags.contains("an example description"));Sourcepub fn add_meta_tag(
self,
name: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn add_meta_tag( self, name: impl Into<String>, content: impl Into<String>, ) -> Self
Adds an additional meta tag.
§Examples
use html_generator::seo::MetaTagsBuilder;
let tags = MetaTagsBuilder::new()
.with_title("t")
.with_description("d")
.add_meta_tag("author", "Jane Doe")
.build()
.unwrap();
assert!(tags.contains(r#"name="author" content="Jane Doe""#));Adds multiple meta tags at once.
§Examples
use html_generator::seo::MetaTagsBuilder;
let extra = vec![
("author".to_string(), "Jane".to_string()),
("robots".to_string(), "index,follow".to_string()),
];
let tags = MetaTagsBuilder::new()
.with_title("t")
.with_description("d")
.add_meta_tags(extra)
.build()
.unwrap();
assert!(tags.contains(r#"name="robots""#));Trait Implementations§
Source§impl Debug for MetaTagsBuilder
impl Debug for MetaTagsBuilder
Source§impl Default for MetaTagsBuilder
impl Default for MetaTagsBuilder
Source§fn default() -> MetaTagsBuilder
fn default() -> MetaTagsBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MetaTagsBuilder
impl RefUnwindSafe for MetaTagsBuilder
impl Send for MetaTagsBuilder
impl Sync for MetaTagsBuilder
impl Unpin for MetaTagsBuilder
impl UnsafeUnpin for MetaTagsBuilder
impl UnwindSafe for MetaTagsBuilder
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