diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-07-10 14:38:32 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-07-10 14:38:32 +0100 |
commit | 3358036c5aaa946b68676baef0c250020df4aa43 (patch) | |
tree | 671e6b7ffbcdb7931a4164e6cdfe0ddd87b486c2 /askama_shared/src | |
parent | 689fc603d5f714d0e1ef8d07a625be14936e4149 (diff) | |
download | askama-3358036c5aaa946b68676baef0c250020df4aa43.tar.gz askama-3358036c5aaa946b68676baef0c250020df4aa43.tar.bz2 askama-3358036c5aaa946b68676baef0c250020df4aa43.zip |
Reorder items in top-down order
Diffstat (limited to 'askama_shared/src')
-rw-r--r-- | askama_shared/src/path.rs | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/askama_shared/src/path.rs b/askama_shared/src/path.rs index 6b3ed0c..8152b5d 100644 --- a/askama_shared/src/path.rs +++ b/askama_shared/src/path.rs @@ -54,32 +54,14 @@ pub fn find_template_from_path(path: &str, start_at: Option<&Path>) -> PathBuf { path.to_owned() } -static CONFIG_FILE_NAME: &str = "askama.toml"; - -#[derive(Deserialize)] -struct RawConfig { - dirs: Option<Vec<String>>, +pub fn template_dirs() -> Vec<PathBuf> { + Config::from_file().dirs } struct Config { dirs: Vec<PathBuf>, } -impl RawConfig { - fn from_file(filename: &PathBuf) -> Option<RawConfig> { - if filename.exists() { - let mut contents = String::new(); - File::open(filename) - .unwrap() - .read_to_string(&mut contents) - .unwrap(); - Some(toml::from_str(&contents).unwrap()) - } else { - None - } - } -} - impl Config { fn from_file() -> Config { let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); @@ -100,10 +82,28 @@ impl Config { } } -pub fn template_dirs() -> Vec<PathBuf> { - Config::from_file().dirs +#[derive(Deserialize)] +struct RawConfig { + dirs: Option<Vec<String>>, +} + +impl RawConfig { + fn from_file(filename: &PathBuf) -> Option<RawConfig> { + if filename.exists() { + let mut contents = String::new(); + File::open(filename) + .unwrap() + .read_to_string(&mut contents) + .unwrap(); + Some(toml::from_str(&contents).unwrap()) + } else { + None + } + } } +static CONFIG_FILE_NAME: &str = "askama.toml"; + #[cfg(test)] mod tests { use super::Path; |