From 1b1ab5e1b94c136d3cd057f8214623a40e707e5f Mon Sep 17 00:00:00 2001
From: Dirkjan Ochtman <dirkjan@ochtman.nl>
Date: Mon, 18 Dec 2023 11:51:37 +0100
Subject: Unbreak reading config from default location

I broke this in 2a4d58cbb2033114890415c98a61e730185d1f83 due to
refactoring for better internal abstractions in askama_derive.
We also don't currently have any tests for the default config path.
---
 askama_derive/src/input.rs | 10 +++++-----
 askama_derive/src/lib.rs   |  4 +++-
 2 files changed, 8 insertions(+), 6 deletions(-)

(limited to 'askama_derive')

diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs
index f46a3c3..d10fd7f 100644
--- a/askama_derive/src/input.rs
+++ b/askama_derive/src/input.rs
@@ -158,8 +158,8 @@ pub(crate) struct TemplateArgs {
     escaping: Option<String>,
     ext: Option<String>,
     syntax: Option<String>,
-    config: String,
-    whitespace: Option<String>,
+    config: Option<String>,
+    pub(crate) whitespace: Option<String>,
 }
 
 impl TemplateArgs {
@@ -258,7 +258,7 @@ impl TemplateArgs {
                 }
             } else if ident == "config" {
                 if let syn::Lit::Str(s) = value.lit {
-                    args.config = read_config_file(Some(&s.value()))?;
+                    args.config = Some(s.value());
                 } else {
                     return Err("config value must be string literal".into());
                 }
@@ -276,8 +276,8 @@ impl TemplateArgs {
         Ok(args)
     }
 
-    pub(crate) fn config(&self) -> Result<Config<'_>, CompileError> {
-        Config::new(&self.config, self.whitespace.as_ref())
+    pub(crate) fn config(&self) -> Result<String, CompileError> {
+        read_config_file(self.config.as_deref())
     }
 }
 
diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs
index 547a449..f9f3d41 100644
--- a/askama_derive/src/lib.rs
+++ b/askama_derive/src/lib.rs
@@ -10,6 +10,7 @@ use proc_macro2::Span;
 use parser::ParseError;
 
 mod config;
+use config::Config;
 mod generator;
 use generator::{Generator, MapChain};
 mod heritage;
@@ -35,7 +36,8 @@ pub fn derive_template(input: TokenStream) -> TokenStream {
 /// value as passed to the `template()` attribute.
 pub(crate) fn build_template(ast: &syn::DeriveInput) -> Result<String, CompileError> {
     let template_args = TemplateArgs::new(ast)?;
-    let config = template_args.config()?;
+    let toml = template_args.config()?;
+    let config = Config::new(&toml, template_args.whitespace.as_ref())?;
     let input = TemplateInput::new(ast, &config, &template_args)?;
 
     let mut templates = HashMap::new();
-- 
cgit