use super::escape as html;
#[derive(Serialize, Deserialize, Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub enum HtmlMetaType {
Name,
HttpEquiv,
Property,
}
impl HtmlMetaType {
pub fn tag_name(self) -> &'static str {
use self::HtmlMetaType::*;
match self {
Name => "name",
HttpEquiv => "http-equiv",
Property => "property",
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct HtmlMeta {
pub tag_type: HtmlMetaType,
pub name: String,
pub value: String,
}
impl HtmlMeta {
pub fn render(&self, buffer: &mut String) {
str_write!(buffer, "<meta {}=\"", self.tag_type.tag_name());
html::escape(buffer, &self.name);
buffer.push_str("\" content=\"");
html::escape(buffer, &self.value);
buffer.push_str("\" />");
}
}