From b3c1fc1a8e16ce414cd53b8e2068bc105f405ff5 Mon Sep 17 00:00:00 2001 From: Maarten de Vries Date: Thu, 10 Jan 2019 23:20:58 +0100 Subject: Remove rerun_if_templates_changed and update README. --- README.md | 17 +---------------- askama/src/lib.rs | 35 ++++------------------------------- testing/Cargo.toml | 3 --- testing/build.rs | 5 ----- 4 files changed, 5 insertions(+), 55 deletions(-) delete mode 100644 testing/build.rs diff --git a/README.md b/README.md index 129ad4a..31a73f3 100644 --- a/README.md +++ b/README.md @@ -68,23 +68,8 @@ First, add the following to your crate's `Cargo.toml`: ```toml # in section [dependencies] -askama = "0.7" +askama = "0.8" -# in section [build-dependencies] -askama = "0.7" -``` - -Because Askama will generate Rust code from your template files, -the crate will need to be recompiled when your templates change. -This is supported by adding a build script, `build.rs`, to your crate. -It needs askama as a build dependency: - -```rust -extern crate askama; - -fn main() { - askama::rerun_if_templates_changed(); -} ``` Now create a directory called `templates` in your crate root. diff --git a/askama/src/lib.rs b/askama/src/lib.rs index e613f50..19d37a3 100644 --- a/askama/src/lib.rs +++ b/askama/src/lib.rs @@ -515,35 +515,8 @@ pub mod gotham { } } -fn visit_dirs(dir: &Path, cb: &dyn Fn(&DirEntry)) -> io::Result<()> { - if dir.is_dir() { - for entry in fs::read_dir(dir)? { - let entry = entry?; - let path = entry.path(); - if path.is_dir() { - visit_dirs(&path, cb)?; - } else { - cb(&entry); - } - } - } - Ok(()) -} - -/// Build script helper to rebuild crates if contained templates have changed +/// Old build script helper to rebuild crates if contained templates have changed /// -/// Iterates over all files in the template directories and writes a -/// `cargo:rerun-if-changed=` line for each of them to stdout. -/// -/// This helper method can be used in build scripts (`build.rs`) in crates -/// that have templates, to make sure the crate gets rebuilt when template -/// source code changes. -pub fn rerun_if_templates_changed() { - let file = read_config_file(); - for template_dir in &shared::Config::new(&file).dirs { - visit_dirs(template_dir, &|e: &DirEntry| { - println!("cargo:rerun-if-changed={}", e.path().to_str().unwrap()); - }) - .unwrap(); - } -} +/// This function is now deprecated and does nothing. +#[deprecated(since="0.8.1", note="file-level dependency tracking is handled automatically without build script")] +pub fn rerun_if_templates_changed() {} diff --git a/testing/Cargo.toml b/testing/Cargo.toml index 427f221..b5a8e99 100644 --- a/testing/Cargo.toml +++ b/testing/Cargo.toml @@ -25,9 +25,6 @@ gotham = { version = "0.3", optional = true } mime = { version = "0.3", optional = true } hyper = { version = "0.12", optional = true } -[build-dependencies] -askama = { path = "../askama", version = "*" } - [dev-dependencies] criterion = "0.2" diff --git a/testing/build.rs b/testing/build.rs deleted file mode 100644 index aab2d59..0000000 --- a/testing/build.rs +++ /dev/null @@ -1,5 +0,0 @@ -use askama; - -fn main() { - askama::rerun_if_templates_changed(); -} -- cgit