aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_derive/src/input.rs9
-rw-r--r--askama_parser/src/lib.rs3
2 files changed, 9 insertions, 3 deletions
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs
index 7314d2e..215d060 100644
--- a/askama_derive/src/input.rs
+++ b/askama_derive/src/input.rs
@@ -119,8 +119,13 @@ impl TemplateInput<'_> {
while let Some(nodes) = nested.pop() {
for n in nodes {
let mut add_to_check = |path: PathBuf| -> Result<(), CompileError> {
- let source = get_template_source(&path)?;
- check.push((path, source));
+ if !map.contains_key(&path) {
+ // Add a dummy entry to `map` in order to prevent adding `path`
+ // multiple times to `check`.
+ map.insert(path.clone(), Parsed::default());
+ let source = get_template_source(&path)?;
+ check.push((path, source));
+ }
Ok(())
};
diff --git a/askama_parser/src/lib.rs b/askama_parser/src/lib.rs
index 4d27d70..e6f133c 100644
--- a/askama_parser/src/lib.rs
+++ b/askama_parser/src/lib.rs
@@ -28,6 +28,7 @@ mod _parsed {
use super::node::Node;
use super::{Ast, ParseError, Syntax};
+ #[derive(Default)]
pub struct Parsed {
// `source` must outlive `ast`, so `ast` must be declared before `source`
ast: Ast<'static>,
@@ -68,7 +69,7 @@ mod _parsed {
pub use _parsed::Parsed;
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct Ast<'a> {
nodes: Vec<Node<'a>>,
}