diff options
| author | 2017-08-16 20:54:48 +0200 | |
|---|---|---|
| committer | 2017-08-16 21:01:08 +0200 | |
| commit | ffcbcd9f19b44a9ea65100e03d6ed5d96b22ce2c (patch) | |
| tree | c41553ddc9c6ef516436a6d54f51272c09a22e70 /askama_derive | |
| parent | f15da8ba3e62c76d23ea4ad87e5f45275885a016 (diff) | |
| download | askama-ffcbcd9f19b44a9ea65100e03d6ed5d96b22ce2c.tar.gz askama-ffcbcd9f19b44a9ea65100e03d6ed5d96b22ce2c.tar.bz2 askama-ffcbcd9f19b44a9ea65100e03d6ed5d96b22ce2c.zip  | |
Pass path to code generation as Path
Diffstat (limited to '')
| -rw-r--r-- | askama_derive/src/generator.rs | 14 | ||||
| -rw-r--r-- | askama_derive/src/lib.rs | 4 | 
2 files changed, 8 insertions, 10 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 5eb456b..60d028b 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -4,12 +4,12 @@ use path;  use quote::{Tokens, ToTokens};  use std::{cmp, hash, str}; -use std::path::{Path, PathBuf}; +use std::path::Path;  use std::collections::HashSet;  use syn; -pub fn generate(ast: &syn::DeriveInput, path: &str, mut nodes: Vec<Node>) -> String { +pub fn generate(ast: &syn::DeriveInput, path: &Path, mut nodes: Vec<Node>) -> String {      let mut base: Option<Expr> = None;      let mut blocks = Vec::new();      let mut block_names = Vec::new(); @@ -52,16 +52,12 @@ pub fn generate(ast: &syn::DeriveInput, path: &str, mut nodes: Vec<Node>) -> Str      gen.result()  } -fn trait_name_for_path(base: &Option<Expr>, path: &str) -> String { +fn trait_name_for_path(base: &Option<Expr>, path: &Path) -> String {      let rooted_path = match *base {          Some(Expr::StrLit(user_path)) => { -            path::find_template_from_path(user_path, Some(Path::new(path))) -        }, -        _ => { -            let mut path_buf = PathBuf::new(); -            path_buf.push(&path); -            path_buf +            path::find_template_from_path(user_path, Some(path))          }, +        _ => path.to_path_buf(),      };      let mut res = String::new(); diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs index cf7f91f..2ddec55 100644 --- a/askama_derive/src/lib.rs +++ b/askama_derive/src/lib.rs @@ -6,6 +6,8 @@ extern crate syn;  use proc_macro::TokenStream; +use std::path::Path; +  mod generator;  mod parser;  mod path; @@ -35,7 +37,7 @@ fn build_template(ast: &syn::DeriveInput) -> String {      if meta.print == Print::Ast || meta.print == Print::All {          println!("{:?}", nodes);      } -    let code = generator::generate(ast, &meta.path, nodes); +    let code = generator::generate(ast, Path::new(&meta.path), nodes);      if meta.print == Print::Code || meta.print == Print::All {          println!("{}", code);      }  | 
