Move parser and generator code into askama crate

This commit is contained in:
Dirkjan Ochtman 2017-01-07 20:33:29 +01:00
parent 9837efad98
commit 5d193ce822
7 changed files with 12 additions and 9 deletions

3
Cargo.lock generated
View File

@ -11,13 +11,14 @@ name = "askama"
version = "0.1.0"
dependencies = [
"htmlescape 0.3.1 (git+https://github.com/veddan/rust-htmlescape)",
"nom 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "askama_derive"
version = "0.1.0"
dependencies = [
"nom 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"askama 0.1.0",
"syn 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@ -6,3 +6,4 @@ workspace = ".."
[dependencies]
htmlescape = { git = "https://github.com/veddan/rust-htmlescape" }
nom = "2.0"

View File

@ -1,7 +1,12 @@
#![feature(proc_macro)]
#[macro_use]
extern crate nom;
pub trait Template {
fn render(&self) -> String;
}
pub mod filters;
pub mod generator;
pub mod parser;

View File

@ -7,5 +7,5 @@ authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
proc-macro = true
[dependencies]
askama = { path = "../askama" }
syn = "0.10"
nom = "2.0"

View File

@ -1,13 +1,9 @@
#![feature(proc_macro, proc_macro_lib)]
#[macro_use]
extern crate nom;
extern crate askama;
extern crate proc_macro;
extern crate syn;
mod generator;
mod parser;
use proc_macro::TokenStream;
use std::fs::File;
use std::io::Read;
@ -65,6 +61,6 @@ pub fn derive_template(input: TokenStream) -> TokenStream {
let name = &ast.ident;
let path = get_path_from_attrs(&ast.attrs);
let src = get_template_source(&path);
let tokens = parser::parse(&src);
generator::generate(name.as_ref(), &tokens).parse().unwrap()
let tokens = askama::parser::parse(&src);
askama::generator::generate(name.as_ref(), &tokens).parse().unwrap()
}