diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-03-06 22:40:04 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-03-06 22:40:04 +0100 |
commit | 664398b225fe916cc0b2b74047e8aea060ea9214 (patch) | |
tree | 9943ad33c662fe2a3fbc7434bae8dfefe0d6bb54 /askama_derive/src/path.rs | |
parent | 0efd0c5cc55eb016472947c56e22e7ffe87ed9d4 (diff) | |
download | askama-664398b225fe916cc0b2b74047e8aea060ea9214.tar.gz askama-664398b225fe916cc0b2b74047e8aea060ea9214.tar.bz2 askama-664398b225fe916cc0b2b74047e8aea060ea9214.zip |
Hide askama_derive dependency inside askama (fixes #2)
Diffstat (limited to 'askama_derive/src/path.rs')
-rw-r--r-- | askama_derive/src/path.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/askama_derive/src/path.rs b/askama_derive/src/path.rs new file mode 100644 index 0000000..96ed8c1 --- /dev/null +++ b/askama_derive/src/path.rs @@ -0,0 +1,19 @@ +use std::env; +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_file: &str) -> String { + let mut path = template_dir(); + path.push(Path::new(tpl_file)); + let mut f = File::open(path).unwrap(); + let mut s = String::new(); + f.read_to_string(&mut s).unwrap(); + s +} |