aboutsummaryrefslogblamecommitdiffstats
path: root/askama_derive/src/lib.rs
blob: 7c92fdcec331a7821bddf5970aa6dc4bb5214ae0 (plain) (tree)
1
2
3
4
5
6
7
8
                                     
                        


                            
 

                                                           


                                                           

                                                                         
                                                 
 
extern crate askama_shared as shared;
extern crate proc_macro;
extern crate syn;

use proc_macro::TokenStream;

#[proc_macro_derive(Template, attributes(template))]
pub fn derive_template(input: TokenStream) -> TokenStream {
    let ast: syn::DeriveInput = syn::parse(input).unwrap();
    match ast.data {
        syn::Data::Struct(ref data) => data,
        _ => panic!("#[derive(Template)] can only be used with structs"),
    };
    shared::build_template(&ast).parse().unwrap()
}