fn build_template(ast: &syn::DeriveInput) -> String {
    let config_toml = read_config_file();
    let config = Config::new(&config_toml);
    let input = TemplateInput::new(ast, &config);
    let source: String = match input.source {
        Source::Source(ref s) => s.clone(),
        Source::Path(_) => get_template_source(&input.path),
    };

    let mut sources = HashMap::new();
    find_used_templates(&input, &mut sources, source);

    let mut parsed = HashMap::new();
    for (path, src) in &sources {
        parsed.insert(path, parse(src, input.syntax));
    }

    let mut contexts = HashMap::new();
    for (path, nodes) in &parsed {
        contexts.insert(*path, Context::new(&input.config, path, nodes));
    }

    let ctx = &contexts[&input.path];
    let heritage = if !ctx.blocks.is_empty() {
        Some(Heritage::new(ctx, &contexts))
    } else {
        None
    };

    if input.print == Print::Ast || input.print == Print::All {
        println!("{:?}", parsed[&input.path]);
    }

    let code = generator::generate(&input, &contexts, &heritage);
    if input.print == Print::Code || input.print == Print::All {
        println!("{}", code);
    }
    code
}
/// Takes a `syn::DeriveInput` and generates source code for it
///
/// Reads the metadata from the `template()` attribute to get the template
/// metadata, then fetches the source from the filesystem. The source is
/// parsed, and the parse tree is fed to the code generator. Will print
/// the parse tree and/or generated source according to the `print` key's
/// value as passed to the `template()` attribute.
Takes a `syn::DeriveInput` and generates source code for it
Reads the metadata from the `template()` attribute to get the template
metadata, then fetches the source from the filesystem. The source is
parsed, and the parse tree is fed to the code generator. Will print
the parse tree and/or generated source according to the `print` key's
value as passed to the `template()` attribute.
Takes a ` syn :: DeriveInput ` and generates source code for it Reads the metadata from the ` template () ` attribute to get the template metadata then fetches the source from the filesystem . The source is parsed and the parse tree is fed to the code generator . Will print the parse tree and / or generated source according to the ` print ` key ' s value as passed to the ` template () ` attribute .
fn build_template(ast: &syn::DeriveInput) -> String {
    let config_toml = read_config_file();
    let config = Config::new(&config_toml);
    let input = TemplateInput::new(ast, &config);
    let source: String = match input.source {
        Source::Source(ref s) => s.clone(),
        Source::Path(_) => get_template_source(&input.path),
    };
    let mut sources = HashMap::new();
    find_used_templates(&input, &mut sources, source);
    let mut parsed = HashMap::new();
    for (path, src) in &sources {
        parsed.insert(path, parse(src, input.syntax));
    }
    let mut contexts = HashMap::new();
    for (path, nodes) in &parsed {
        contexts.insert(*path, Context::new(&input.config, path, nodes));
    }
    let ctx = &contexts[&input.path];
    let heritage = if !ctx.blocks.is_empty() {
        Some(Heritage::new(ctx, &contexts))
    } else {
        None
    };
    if input.print == Print::Ast || input.print == Print::All {
        println!("{:?}", parsed[&input.path]);
    }
    let code = generator::generate(&input, &contexts, &heritage);
    if input.print == Print::Code || input.print == Print::All {
        println!("{}", code);
    }
    code
}
fn build_template ( ast : & syn :: DeriveInput ) -> String { let config_toml = read_config_file ( ) ; let config = Config :: new ( & config_toml ) ; let input = TemplateInput :: new ( ast , & config ) ; let source : String = match input . source { Source :: Source ( ref s ) => s . clone ( ) , Source :: Path ( _ ) => get_template_source ( & input . path ) , } ; let mut sources = HashMap :: new ( ) ; find_used_templates ( & input , & mut sources , source ) ; let mut parsed = HashMap :: new ( ) ; for ( path , src ) in & sources { parsed . insert ( path , parse ( src , input . syntax ) ) ; } let mut contexts = HashMap :: new ( ) ; for ( path , nodes ) in & parsed { contexts . insert ( * path , Context :: new ( & input . config , path , nodes ) ) ; } let ctx = & contexts [ & input . path ] ; let heritage = if ! ctx . blocks . is_empty ( ) { Some ( Heritage :: new ( ctx , & contexts ) ) } else { None } ; if input . print == Print :: Ast || input . print == Print :: All { println ! ( " " parsed [ input path ] ) ; } let code = generator :: generate ( & input , & contexts , & heritage ) ; if input . print == Print :: Code || input . print == Print :: All { println ! ( " " code ) ; } code }
Takes a `syn::DeriveInput` and generates source code for it
Reads the metadata from the `template()` attribute to get the template
metadata, then fetches the source from the filesystem.
Takes a ` syn :: DeriveInput ` and generates source code for it Reads the metadata from the ` template () ` attribute to get the template metadata then fetches the source from the filesystem .
ast
&syn::DeriveInput
ast
&syn::DeriveInput