From 8d5dc03406214269bdb9481e90ed81326a3893c5 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 29 Apr 2023 15:00:06 +0200 Subject: [PATCH] add quotes when possible, trailing space at the end --- src/template.rs | 11 ++++++++--- templates/metadata.html | 14 +++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/template.rs b/src/template.rs index 9e80490..6c1af91 100644 --- a/src/template.rs +++ b/src/template.rs @@ -39,6 +39,11 @@ struct Data { data: T, } +/// Add quotes around a string +fn add_quotes(string: String) -> String { + format!("\"{}\"", string) +} + impl Template { pub fn render(&self, template: &str, data: C, info: Infos) -> String { let mut templates: Ramhorns = Ramhorns::lazy(&self.directory).unwrap(); @@ -47,9 +52,9 @@ impl Template { tplt.render(&Data { app_name: self.app_name.to_owned(), page_title: info.page_title, - page_desc: info.page_desc, - page_kw: info.page_kw, - url: info.url, + page_desc: info.page_desc.map(add_quotes), + page_kw: info.page_kw.map(add_quotes), + url: add_quotes(info.url), data, }) } diff --git a/templates/metadata.html b/templates/metadata.html index 54e0b74..b8695f6 100644 --- a/templates/metadata.html +++ b/templates/metadata.html @@ -2,22 +2,22 @@ {{#page_title}} {{/page_title}} {{#page_desc}} - + {{/page_desc}} {{#page_kw}} - + {{/page_kw}} - - + + - + - - + +