aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-07-10 15:46:55 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-07-10 15:46:55 +0100
commitab9891f9c5291b8afb2f052d156780089efd99cd (patch)
treeeb90785d99ebfd240abd19e0fe09e6f131358395
parentc7cc34f3e956173eb9e03decaf08e0ea6ea28525 (diff)
downloadaskama-ab9891f9c5291b8afb2f052d156780089efd99cd.tar.gz
askama-ab9891f9c5291b8afb2f052d156780089efd99cd.tar.bz2
askama-ab9891f9c5291b8afb2f052d156780089efd99cd.zip
Use Config type for build script helper
Diffstat (limited to '')
-rw-r--r--askama/src/lib.rs2
-rw-r--r--askama_shared/src/lib.rs6
-rw-r--r--askama_shared/src/path.rs4
3 files changed, 4 insertions, 8 deletions
diff --git a/askama/src/lib.rs b/askama/src/lib.rs
index aaa1c3b..d55baef 100644
--- a/askama/src/lib.rs
+++ b/askama/src/lib.rs
@@ -393,7 +393,7 @@ fn visit_dirs(dir: &Path, cb: &Fn(&DirEntry)) -> io::Result<()> {
/// that have templates, to make sure the crate gets rebuilt when template
/// source code changes.
pub fn rerun_if_templates_changed() {
- for template_dir in path::template_dirs().iter() {
+ for template_dir in &shared::Config::new().dirs {
visit_dirs(template_dir, &|e: &DirEntry| {
println!("cargo:rerun-if-changed={}", e.path().to_str().unwrap());
}).unwrap();
diff --git a/askama_shared/src/lib.rs b/askama_shared/src/lib.rs
index f940021..e379b72 100644
--- a/askama_shared/src/lib.rs
+++ b/askama_shared/src/lib.rs
@@ -19,12 +19,12 @@ pub use escaping::MarkupDisplay;
pub mod filters;
pub mod path;
-struct Config {
- dirs: Vec<PathBuf>,
+pub struct Config {
+ pub dirs: Vec<PathBuf>,
}
impl Config {
- fn new() -> Config {
+ pub fn new() -> Config {
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let filename = root.join(CONFIG_FILE_NAME);
diff --git a/askama_shared/src/path.rs b/askama_shared/src/path.rs
index b1a1e6a..4197376 100644
--- a/askama_shared/src/path.rs
+++ b/askama_shared/src/path.rs
@@ -37,10 +37,6 @@ pub fn find_template_from_path(path: &str, start_at: Option<&Path>) -> PathBuf {
panic!("template {:?} not found in directories {:?}", path, config.dirs)
}
-pub fn template_dirs() -> Vec<PathBuf> {
- Config::new().dirs
-}
-
#[cfg(test)]
mod tests {
use super::{find_template_from_path, get_template_source};