html_site_generator/html/title.rs
1use std::io::Write;
2
3use anyhow::Result;
4
5use crate::html::IntoHtmlNode;
6
7#[derive(Debug)]
8pub struct Title {
9 text: String,
10}
11
12impl Title {
13 pub fn new<S: Into<String>>(content: S) -> Self {
14 Title {
15 text: content.into(),
16 }
17 }
18}
19
20impl IntoHtmlNode for Title {
21 fn transform_into_html_node(&self, buffer: &mut dyn Write) -> Result<()> {
22 writeln!(buffer, "<title>{}</title>", self.text)?;
23
24 Ok(())
25 }
26}