diff options
author | Maarten de Vries <maarten@de-vri.es> | 2019-01-10 23:20:58 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2019-01-11 16:30:51 +0100 |
commit | b3c1fc1a8e16ce414cd53b8e2068bc105f405ff5 (patch) | |
tree | f47b065f20a25699bf39ad2099b6e1db85c7cac7 | |
parent | 07904728f9708de152beea49ce67cafcd7225aa2 (diff) | |
download | askama-b3c1fc1a8e16ce414cd53b8e2068bc105f405ff5.tar.gz askama-b3c1fc1a8e16ce414cd53b8e2068bc105f405ff5.tar.bz2 askama-b3c1fc1a8e16ce414cd53b8e2068bc105f405ff5.zip |
Remove rerun_if_templates_changed and update README.
-rw-r--r-- | README.md | 17 | ||||
-rw-r--r-- | askama/src/lib.rs | 35 | ||||
-rw-r--r-- | testing/Cargo.toml | 3 | ||||
-rw-r--r-- | testing/build.rs | 5 |
4 files changed, 5 insertions, 55 deletions
@@ -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(); -} |