From 0bc54d366ae02347bd902111a311435790b46d2f Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 8 Feb 2017 19:12:21 +0100 Subject: Expose less granular API in askama crate --- askama_derive/src/lib.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'askama_derive') diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs index ba5dec4..59d1ae1 100644 --- a/askama_derive/src/lib.rs +++ b/askama_derive/src/lib.rs @@ -3,9 +3,6 @@ extern crate proc_macro; extern crate syn; use proc_macro::TokenStream; -use std::fs::File; -use std::io::Read; -use std::path::{Path, PathBuf}; fn get_path_from_attrs(attrs: &Vec) -> String { for attr in attrs { @@ -35,17 +32,6 @@ fn get_path_from_attrs(attrs: &Vec) -> String { panic!("template annotation not found"); } -fn get_template_source(tpl_file: &str) -> String { - let root = ::std::env::var("CARGO_MANIFEST_DIR").unwrap(); - let mut path = PathBuf::from(root); - path.push("templates"); - path.push(Path::new(tpl_file)); - let mut f = File::open(path).unwrap(); - let mut s = String::new(); - f.read_to_string(&mut s).unwrap(); - s -} - #[proc_macro_derive(Template, attributes(template))] pub fn derive_template(input: TokenStream) -> TokenStream { let source = input.to_string(); @@ -57,7 +43,5 @@ pub fn derive_template(input: TokenStream) -> TokenStream { }; let path = get_path_from_attrs(&ast.attrs); - let src = get_template_source(&path); - let nodes = askama::parser::parse(&src); - askama::generator::generate(&ast, &path, nodes).parse().unwrap() + askama::build_template(&path, &ast).parse().unwrap() } -- cgit