mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-28 13:30:59 +00:00
Added path and ext tests
This commit is contained in:
parent
d6c05d8eb9
commit
7b954cd788
1
testing/templates/foo.html
Normal file
1
testing/templates/foo.html
Normal file
@ -0,0 +1 @@
|
||||
foo.html
|
1
testing/templates/foo.html.jinja
Normal file
1
testing/templates/foo.html.jinja
Normal file
@ -0,0 +1 @@
|
||||
foo.html.jinja
|
1
testing/templates/foo.jinja
Normal file
1
testing/templates/foo.jinja
Normal file
@ -0,0 +1 @@
|
||||
foo.jinja
|
67
testing/tests/ext.rs
Normal file
67
testing/tests/ext.rs
Normal file
@ -0,0 +1,67 @@
|
||||
use askama::Template;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "foo.html")]
|
||||
struct PathHtml;
|
||||
|
||||
#[test]
|
||||
fn test_path_ext_html() {
|
||||
let t = PathHtml;
|
||||
assert_eq!(t.render().unwrap(), "foo.html");
|
||||
assert_eq!(t.extension(), Some("html"));
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "foo.jinja")]
|
||||
struct PathJinja;
|
||||
|
||||
#[test]
|
||||
fn test_path_ext_jinja() {
|
||||
let t = PathJinja;
|
||||
assert_eq!(t.render().unwrap(), "foo.jinja");
|
||||
assert_eq!(t.extension(), Some("jinja"));
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "foo.html.jinja")]
|
||||
struct PathHtmlJinja;
|
||||
|
||||
#[test]
|
||||
fn test_path_ext_html_jinja() {
|
||||
let t = PathHtmlJinja;
|
||||
assert_eq!(t.render().unwrap(), "foo.html.jinja");
|
||||
assert_eq!(t.extension(), Some("html"));
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "foo.html", ext = "txt")]
|
||||
struct PathHtmlAndExtTxt;
|
||||
|
||||
#[test]
|
||||
fn test_path_ext_html_and_ext_txt() {
|
||||
let t = PathHtmlAndExtTxt;
|
||||
assert_eq!(t.render().unwrap(), "foo.html");
|
||||
assert_eq!(t.extension(), Some("txt"));
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "foo.jinja", ext = "txt")]
|
||||
struct PathJinjaAndExtTxt;
|
||||
|
||||
#[test]
|
||||
fn test_path_ext_jinja_and_ext_txt() {
|
||||
let t = PathJinjaAndExtTxt;
|
||||
assert_eq!(t.render().unwrap(), "foo.jinja");
|
||||
assert_eq!(t.extension(), Some("txt"));
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "foo.html.jinja", ext = "txt")]
|
||||
struct PathHtmlJinjaAndExtTxt;
|
||||
|
||||
#[test]
|
||||
fn test_path_ext_html_jinja_and_ext_txt() {
|
||||
let t = PathHtmlJinjaAndExtTxt;
|
||||
assert_eq!(t.render().unwrap(), "foo.html.jinja");
|
||||
assert_eq!(t.extension(), Some("txt"));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user