diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-08-16 20:40:34 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-08-16 20:40:34 +0200 |
commit | 7efd70297d12a643b858f006006c04b5d86b7d92 (patch) | |
tree | fa388cf0b3e1bbc50569d01552f0de42a08dcbd8 /askama_derive | |
parent | 39b9e6e491919d1f4e7f79bf78e79da43d4d003b (diff) | |
download | askama-7efd70297d12a643b858f006006c04b5d86b7d92.tar.gz askama-7efd70297d12a643b858f006006c04b5d86b7d92.tar.bz2 askama-7efd70297d12a643b858f006006c04b5d86b7d92.zip |
Simplify relative path handling in find_template_from_path()
Diffstat (limited to 'askama_derive')
-rw-r--r-- | askama_derive/src/path.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/askama_derive/src/path.rs b/askama_derive/src/path.rs index a78daf8..bf43568 100644 --- a/askama_derive/src/path.rs +++ b/askama_derive/src/path.rs @@ -24,16 +24,13 @@ pub fn get_template_source(tpl_path: &Path) -> String { pub fn find_template_from_path<'a>(path: &str, start_at: Option<&str>) -> PathBuf { let root = template_dir(); - match start_at { - Some(rel) => { - let mut fs_rel_path = root.clone(); - fs_rel_path.push(rel); - fs_rel_path = fs_rel_path.with_file_name(path); - if fs_rel_path.exists() { - return fs_rel_path.strip_prefix(&root).unwrap().to_owned(); - } - }, - None => {}, + if let Some(rel) = start_at { + let mut fs_rel_path = root.clone(); + fs_rel_path.push(rel); + fs_rel_path = fs_rel_path.with_file_name(path); + if fs_rel_path.exists() { + return fs_rel_path.strip_prefix(&root).unwrap().to_owned(); + } } let mut fs_abs_path = root.clone(); |