diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-07-11 22:30:10 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-07-11 22:30:10 +0100 |
commit | c8d9a6326d69471145ce6ec7742389a3f9186f1a (patch) | |
tree | c51c0f0c6034525a00fc809d62c9a112006febdd /askama_derive/src/input.rs | |
parent | 987354946cde37ddd05d5316f7b581c9dd6f0131 (diff) | |
download | askama-c8d9a6326d69471145ce6ec7742389a3f9186f1a.tar.gz askama-c8d9a6326d69471145ce6ec7742389a3f9186f1a.tar.bz2 askama-c8d9a6326d69471145ce6ec7742389a3f9186f1a.zip |
Move find_template_from_path() into Config
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/input.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs index 6e349da..14531cf 100644 --- a/askama_derive/src/input.rs +++ b/askama_derive/src/input.rs @@ -2,7 +2,7 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use shared::path; +use shared::Config; use std::path::PathBuf; @@ -10,6 +10,7 @@ use syn; pub struct TemplateInput<'a> { pub ast: &'a syn::DeriveInput, + pub config: Config, pub source: Source, pub print: Print, pub escaping: EscapeMode, @@ -96,9 +97,10 @@ impl<'a> TemplateInput<'a> { // Validate the `source` and `ext` value together, since they are // related. In case `source` was used instead of `path`, the value // of `ext` is merged into a synthetic `path` value here. + let config = Config::new(); let source = source.expect("template path or source not found in attributes"); let path = match (&source, &ext) { - (&Source::Path(ref path), None) => path::find_template_from_path(path, None), + (&Source::Path(ref path), None) => config.find_template(path, None), (&Source::Source(_), Some(ext)) => PathBuf::from(format!("{}.{}", ast.ident, ext)), (&Source::Path(_), Some(_)) => { panic!("'ext' attribute cannot be used with 'path' attribute") @@ -124,6 +126,7 @@ impl<'a> TemplateInput<'a> { TemplateInput { ast, + config, source, print, escaping: escaping.unwrap_or_else(|| EscapeMode::from_path(&path)), |