aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src
diff options
context:
space:
mode:
authorLibravatar Marvin Jütte <marvin@juette.cc>2023-11-07 13:49:37 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-11-09 11:45:42 +0100
commitea4dab1251eccc63e8717c99327282b7af04671f (patch)
tree8a952288a4b3eb3f1510e5f7e4a684c4573a98c9 /askama_derive/src
parent02602fde70f6fd4de1279bef037027f70a2cedab (diff)
downloadaskama-ea4dab1251eccc63e8717c99327282b7af04671f.tar.gz
askama-ea4dab1251eccc63e8717c99327282b7af04671f.tar.bz2
askama-ea4dab1251eccc63e8717c99327282b7af04671f.zip
add support for svg file extension
Diffstat (limited to 'askama_derive/src')
-rw-r--r--askama_derive/src/config.rs7
-rw-r--r--askama_derive/src/input.rs5
2 files changed, 9 insertions, 3 deletions
diff --git a/askama_derive/src/config.rs b/askama_derive/src/config.rs
index 47801cd..2347f6c 100644
--- a/askama_derive/src/config.rs
+++ b/askama_derive/src/config.rs
@@ -299,7 +299,7 @@ pub(crate) fn get_template_source(tpl_path: &Path) -> std::result::Result<String
static CONFIG_FILE_NAME: &str = "askama.toml";
static DEFAULT_SYNTAX_NAME: &str = "default";
static DEFAULT_ESCAPERS: &[(&[&str], &str)] = &[
- (&["html", "htm", "xml"], "::askama::Html"),
+ (&["html", "htm", "svg", "xml"], "::askama::Html"),
(&["md", "none", "txt", "yml", ""], "::askama::Text"),
(&["j2", "jinja", "jinja2"], "::askama::Html"),
];
@@ -564,7 +564,10 @@ mod tests {
config.escapers,
vec![
(str_set(&["js"]), "::askama::Js".into()),
- (str_set(&["html", "htm", "xml"]), "::askama::Html".into()),
+ (
+ str_set(&["html", "htm", "svg", "xml"]),
+ "::askama::Html".into()
+ ),
(
str_set(&["md", "none", "txt", "yml", ""]),
"::askama::Text".into()
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs
index ee9b942..f46a3c3 100644
--- a/askama_derive/src/input.rs
+++ b/askama_derive/src/input.rs
@@ -345,7 +345,7 @@ pub(crate) fn extension_to_mime_type(ext: &str) -> Mime {
basic_type
}
-const TEXT_TYPES: [(Mime, Mime); 6] = [
+const TEXT_TYPES: [(Mime, Mime); 7] = [
(mime::TEXT_PLAIN, mime::TEXT_PLAIN_UTF_8),
(mime::TEXT_HTML, mime::TEXT_HTML_UTF_8),
(mime::TEXT_CSS, mime::TEXT_CSS_UTF_8),
@@ -358,6 +358,7 @@ const TEXT_TYPES: [(Mime, Mime); 6] = [
mime::APPLICATION_JAVASCRIPT,
mime::APPLICATION_JAVASCRIPT_UTF_8,
),
+ (mime::IMAGE_SVG, mime::IMAGE_SVG),
];
#[cfg(test)]
@@ -369,10 +370,12 @@ mod tests {
assert_eq!(extension(Path::new("foo-bar.txt")), Some("txt"));
assert_eq!(extension(Path::new("foo-bar.html")), Some("html"));
assert_eq!(extension(Path::new("foo-bar.unknown")), Some("unknown"));
+ assert_eq!(extension(Path::new("foo-bar.svg")), Some("svg"));
assert_eq!(extension(Path::new("foo/bar/baz.txt")), Some("txt"));
assert_eq!(extension(Path::new("foo/bar/baz.html")), Some("html"));
assert_eq!(extension(Path::new("foo/bar/baz.unknown")), Some("unknown"));
+ assert_eq!(extension(Path::new("foo/bar/baz.svg")), Some("svg"));
}
#[test]