aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_derive/src/lib.rs18
1 files changed, 1 insertions, 17 deletions
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<syn::Attribute>) -> String {
for attr in attrs {
@@ -35,17 +32,6 @@ fn get_path_from_attrs(attrs: &Vec<syn::Attribute>) -> 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()
}