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" version = "0.1.0"
dependencies = [ dependencies = [
"htmlescape 0.3.1 (git+https://github.com/veddan/rust-htmlescape)", "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]] [[package]]
name = "askama_derive" name = "askama_derive"
version = "0.1.0" version = "0.1.0"
dependencies = [ 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)", "syn 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View File

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

View File

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

View File

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

View File

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