diff --git a/maud_extras/lib.rs b/maud_extras/lib.rs index 54ee011..5b4db81 100644 --- a/maud_extras/lib.rs +++ b/maud_extras/lib.rs @@ -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()) + } + } +}