diff options
author | mash <mashedcode@users.noreply.github.com> | 2018-06-29 13:51:09 +0000 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-07-02 09:25:27 +0200 |
commit | 0c9a455180c27e1362a78dd335ee6a0656b3b2cf (patch) | |
tree | 8c6975f0d96071a146b480b52333bf61d1677ee6 /askama_derive/src/lib.rs | |
parent | 23db04ea5ff9cca2008a1a3bb6d0dce452f519d3 (diff) | |
download | askama-0c9a455180c27e1362a78dd335ee6a0656b3b2cf.tar.gz askama-0c9a455180c27e1362a78dd335ee6a0656b3b2cf.tar.bz2 askama-0c9a455180c27e1362a78dd335ee6a0656b3b2cf.zip |
Only pass path to context
Diffstat (limited to 'askama_derive/src/lib.rs')
-rw-r--r-- | askama_derive/src/lib.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs index 7c0387f..27f02d1 100644 --- a/askama_derive/src/lib.rs +++ b/askama_derive/src/lib.rs @@ -53,7 +53,7 @@ fn build_template(ast: &syn::DeriveInput) -> String { let mut contexts = HashMap::new(); for (path, nodes) in &parsed { - contexts.insert(*path, Context::new(&input, nodes)); + contexts.insert(*path, Context::new(path, nodes)); } if input.print == Print::Ast || input.print == Print::All { @@ -98,7 +98,7 @@ pub(crate) struct Context<'a> { } impl<'a> Context<'a> { - fn new<'n>(input: &'n TemplateInput, nodes: &'n [Node<'n>]) -> Context<'n> { + fn new<'n>(path: &PathBuf, nodes: &'n [Node<'n>]) -> Context<'n> { let mut extends = None; let mut blocks = Vec::new(); let mut macros = HashMap::new(); @@ -106,10 +106,10 @@ impl<'a> Context<'a> { for n in nodes { match n { - Node::Extends(Expr::StrLit(path)) => match extends { + Node::Extends(Expr::StrLit(extends_path)) => match extends { Some(_) => panic!("multiple extend blocks found"), None => { - extends = Some(path::find_template_from_path(path, Some(&input.path))); + extends = Some(path::find_template_from_path(extends_path, Some(path))); } }, def @ Node::BlockDef(_, _, _, _) => { @@ -119,7 +119,7 @@ impl<'a> Context<'a> { macros.insert(*name, m); } Node::Import(_, import_path, scope) => { - let path = path::find_template_from_path(import_path, Some(&input.path)); + let path = path::find_template_from_path(import_path, Some(path)); imports.insert(*scope, path); } _ => {} |