diff options
author | 2017-08-08 20:29:43 +0200 | |
---|---|---|
committer | 2017-08-08 20:29:43 +0200 | |
commit | d40f5a3ea60a1f8c9d02c955835cb966873b4082 (patch) | |
tree | d13d856e05e34791e2912f60f8583399ce4b0b8d /askama_derive/src/path.rs | |
parent | 946e8c758729c5fce42b137a2bc7e31b8bd49ade (diff) | |
download | askama-d40f5a3ea60a1f8c9d02c955835cb966873b4082.tar.gz askama-d40f5a3ea60a1f8c9d02c955835cb966873b4082.tar.bz2 askama-d40f5a3ea60a1f8c9d02c955835cb966873b4082.zip |
Reorganize code order in askama_derive modules
Diffstat (limited to 'askama_derive/src/path.rs')
-rw-r--r-- | askama_derive/src/path.rs | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/askama_derive/src/path.rs b/askama_derive/src/path.rs index b51f5f3..03ab20d 100644 --- a/askama_derive/src/path.rs +++ b/askama_derive/src/path.rs @@ -3,10 +3,23 @@ use std::fs::File; use std::io::Read; use std::path::{Path, PathBuf}; -fn template_dir() -> PathBuf { - let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); - path.push("templates"); - path +pub fn get_template_source(tpl_path: &Path) -> String { + let mut path = template_dir(); + path.push(tpl_path); + let mut f = match File::open(&path) { + Err(_) => { + let msg = format!("unable to open template file '{}'", + &path.to_str().unwrap()); + panic!(msg); + }, + Ok(f) => f, + }; + let mut s = String::new(); + f.read_to_string(&mut s).unwrap(); + if s.ends_with('\n') { + let _ = s.pop(); + } + s } pub fn find_template_from_path<'a>(path: &str, start_at: Option<&str>) -> PathBuf { @@ -33,23 +46,10 @@ pub fn find_template_from_path<'a>(path: &str, start_at: Option<&str>) -> PathBu } } -pub fn get_template_source(tpl_path: &Path) -> String { - let mut path = template_dir(); - path.push(tpl_path); - let mut f = match File::open(&path) { - Err(_) => { - let msg = format!("unable to open template file '{}'", - &path.to_str().unwrap()); - panic!(msg); - }, - Ok(f) => f, - }; - let mut s = String::new(); - f.read_to_string(&mut s).unwrap(); - if s.ends_with('\n') { - let _ = s.pop(); - } - s +fn template_dir() -> PathBuf { + let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + path.push("templates"); + path } #[cfg(test)] |