aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-10-10 15:10:12 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-11-01 12:52:09 +0100
commitbabea28312387a22642cb974cc4b97e9fe7fed49 (patch)
tree4e4a2b492574009d98f4d75b74d7e717efecef9a /askama_derive
parent2a4d58cbb2033114890415c98a61e730185d1f83 (diff)
downloadaskama-babea28312387a22642cb974cc4b97e9fe7fed49.tar.gz
askama-babea28312387a22642cb974cc4b97e9fe7fed49.tar.bz2
askama-babea28312387a22642cb974cc4b97e9fe7fed49.zip
Build Config from TemplateArgs
Diffstat (limited to '')
-rw-r--r--askama_derive/src/input.rs18
-rw-r--r--askama_derive/src/lib.rs3
2 files changed, 12 insertions, 9 deletions
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs
index 45da7f0..ee9b942 100644
--- a/askama_derive/src/input.rs
+++ b/askama_derive/src/input.rs
@@ -153,13 +153,13 @@ impl TemplateInput<'_> {
#[derive(Debug, Default)]
pub(crate) struct TemplateArgs {
- pub(crate) source: Option<Source>,
- pub(crate) print: Print,
- pub(crate) escaping: Option<String>,
- pub(crate) ext: Option<String>,
- pub(crate) syntax: Option<String>,
- pub(crate) config: String,
- pub(crate) whitespace: Option<String>,
+ source: Option<Source>,
+ print: Print,
+ escaping: Option<String>,
+ ext: Option<String>,
+ syntax: Option<String>,
+ config: String,
+ whitespace: Option<String>,
}
impl TemplateArgs {
@@ -275,6 +275,10 @@ impl TemplateArgs {
Ok(args)
}
+
+ pub(crate) fn config(&self) -> Result<Config<'_>, CompileError> {
+ Config::new(&self.config, self.whitespace.as_ref())
+ }
}
#[inline]
diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs
index a133813..a5eb67a 100644
--- a/askama_derive/src/lib.rs
+++ b/askama_derive/src/lib.rs
@@ -10,7 +10,6 @@ use proc_macro2::Span;
use parser::ParseError;
mod config;
-use config::Config;
mod generator;
use generator::{Generator, MapChain};
mod heritage;
@@ -36,7 +35,7 @@ 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 = Config::new(&template_args.config, template_args.whitespace.as_ref())?;
+ let config = template_args.config()?;
let input = TemplateInput::new(ast, &config, &template_args)?;
let mut templates = HashMap::new();