aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src
diff options
context:
space:
mode:
Diffstat (limited to 'askama_shared/src')
-rw-r--r--askama_shared/src/path.rs44
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;