templates: expose escape_html function to fix tests

This commit is contained in:
Quentin Gliech
2023-10-02 15:37:07 +02:00
parent a7e703e56a
commit a5033d9c69
3 changed files with 18 additions and 1 deletions

8
Cargo.lock generated
View File

@@ -3306,6 +3306,7 @@ dependencies = [
"tracing",
"ulid",
"url",
"v_htmlescape",
"walkdir",
]
@@ -3410,6 +3411,7 @@ dependencies = [
"self_cell",
"serde",
"serde_json",
"v_htmlescape",
]
[[package]]
@@ -6190,6 +6192,12 @@ dependencies = [
"serde",
]
[[package]]
name = "v_htmlescape"
version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c"
[[package]]
name = "valuable"
version = "0.1.0"

View File

@@ -16,10 +16,11 @@ walkdir = "2.4.0"
anyhow.workspace = true
thiserror.workspace = true
minijinja = { workspace = true, features = ["loader", "json"] }
minijinja = { workspace = true, features = ["loader", "json", "speedups"] }
serde.workspace = true
serde_json.workspace = true
serde_urlencoded = "0.7.1"
v_htmlescape = "0.15.8"
camino.workspace = true
chrono.workspace = true

View File

@@ -57,6 +57,14 @@ pub use self::{
forms::{FieldError, FormError, FormField, FormState, ToFormState},
};
/// Escape the given string for use in HTML
///
/// It uses the same crate as the one used by the minijinja templates
#[must_use]
pub fn escape_html(input: &str) -> String {
v_htmlescape::escape(input).to_string()
}
/// Wrapper around [`minijinja::Environment`] helping rendering the various
/// templates
#[derive(Debug, Clone)]