aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-10-06 11:53:05 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-11-01 12:52:09 +0100
commita057f81c051ae71329c5377b0351e6a09231c30d (patch)
tree4aac6fe8ab5be5f78f2d9a65c67aac450052d3e4 /askama_derive/src
parent4de28e4584727d4df1cef1c8844db864df128995 (diff)
downloadaskama-a057f81c051ae71329c5377b0351e6a09231c30d.tar.gz
askama-a057f81c051ae71329c5377b0351e6a09231c30d.tar.bz2
askama-a057f81c051ae71329c5377b0351e6a09231c30d.zip
Inline some logic into find_used_templates()
Diffstat (limited to 'askama_derive/src')
-rw-r--r--askama_derive/src/input.rs6
-rw-r--r--askama_derive/src/lib.rs10
2 files changed, 8 insertions, 8 deletions
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs
index 03817f1..891dec7 100644
--- a/askama_derive/src/input.rs
+++ b/askama_derive/src/input.rs
@@ -104,8 +104,12 @@ impl TemplateInput<'_> {
pub(crate) fn find_used_templates(
&self,
map: &mut HashMap<PathBuf, Parsed>,
- source: String,
) -> Result<(), CompileError> {
+ let source = match &self.source {
+ Source::Source(s) => s.clone(),
+ Source::Path(_) => get_template_source(&self.path)?,
+ };
+
let mut dependency_graph = Vec::new();
let mut check = vec![(self.path.clone(), source)];
while let Some((path, source)) = check.pop() {
diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs
index 37e8a3b..3046f9d 100644
--- a/askama_derive/src/lib.rs
+++ b/askama_derive/src/lib.rs
@@ -10,13 +10,13 @@ use proc_macro2::Span;
use parser::ParseError;
mod config;
-use config::{get_template_source, read_config_file, Config};
+use config::{read_config_file, Config};
mod generator;
use generator::{Generator, MapChain};
mod heritage;
use heritage::{Context, Heritage};
mod input;
-use input::{Print, Source, TemplateArgs, TemplateInput};
+use input::{Print, TemplateArgs, TemplateInput};
#[proc_macro_derive(Template, attributes(template))]
pub fn derive_template(input: TokenStream) -> TokenStream {
@@ -39,13 +39,9 @@ pub(crate) fn build_template(ast: &syn::DeriveInput) -> Result<String, CompileEr
let config_toml = read_config_file(template_args.config_path.as_deref())?;
let config = Config::new(&config_toml, template_args.whitespace.as_ref())?;
let input = TemplateInput::new(ast, &config, template_args)?;
- let source = match input.source {
- Source::Source(ref s) => s.clone(),
- Source::Path(_) => get_template_source(&input.path)?,
- };
let mut templates = HashMap::new();
- input.find_used_templates(&mut templates, source)?;
+ input.find_used_templates(&mut templates)?;
let mut contexts = HashMap::new();
for (path, parsed) in &templates {