Add meta title element

This commit is contained in:
Ernestas Poskus 2016-12-11 22:14:10 +02:00
parent 4d3e2cc775
commit 5410e73e11

View file

@ -82,3 +82,29 @@ impl<T: AsRef<str>, U: AsRef<str>> Render for Meta<T, U> {
}
}
}
/// Generate <title> element.
///
/// # Example
///
/// ```rust
/// # #![feature(plugin)]
/// # #![plugin(maud_macros)]
/// # extern crate maud;
/// # extern crate maud_extras;
/// # use maud_extras::*;
/// # fn main() {
/// let markup = html! { (Title("Maud")) };
/// assert_eq!(markup.into_string(),
/// r#"<title>Maud</title>"#);
/// # }
/// ```
pub struct Title<T: AsRef<str>>(pub T);
impl<T: AsRef<str>> Render for Title<T> {
fn render(&self) -> Markup {
html! {
title (self.0.as_ref())
}
}
}