aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/lib.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-08 19:12:21 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-08 19:12:21 +0100
commit0bc54d366ae02347bd902111a311435790b46d2f (patch)
tree97647065a36d6ba90534eb32eabe5a6fe2ef4d9f /askama_derive/src/lib.rs
parent66dd21c8577330c625f32c7cf59635dbc7c36115 (diff)
downloadaskama-0bc54d366ae02347bd902111a311435790b46d2f.tar.gz
askama-0bc54d366ae02347bd902111a311435790b46d2f.tar.bz2
askama-0bc54d366ae02347bd902111a311435790b46d2f.zip
Expose less granular API in askama crate
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()
}