fn render_template_files(config: &RenderCommand, context: Context, writer: &mut Write) {
    let success = AtomicBool::new(false);

    for template_file in &config.template_files {
        log::info!("Rendering {}...", template_file.display());

        match fs::read_to_string(template_file) {
            Ok(s) => match Tera::one_off(s.as_str(), context.clone(), config.autoescape) {
                // cool, we've been able to read the template file
                Ok(s) => {
                    // we have successfully rendered the template
                    write!(writer, "{}", s).unwrap_or_else(|e| {
                        log::error!("Unable to write rendered template to output: {}", e);
                        process::exit(1);
                    });

                    success.store(true, Ordering::SeqCst);
                }
                Err(e) => {
                    // rendering the template has failed
                    log::error!(
                        "Unable to render template file {}: {:?}",
                        template_file.display(),
                        e
                    );
                }
            },
            Err(e) => {
                // we weren't able to read the template file
                log::error!(
                    "Unable to read template file {}: {}",
                    template_file.display(),
                    e
                );
            }
        }
    }

    if !success.load(Ordering::SeqCst) {
        log::error!("Unable to successfully render any provided templates.");
        process::exit(1);
    }
}
/// Render a list of template files from the configuration.
Render a list of template files from the configuration.
Render a list of template files from the configuration .
fn render_template_files(config: &RenderCommand, context: Context, writer: &mut Write) {
    let success = AtomicBool::new(false);
    for template_file in &config.template_files {
        log::info!("Rendering {}...", template_file.display());
        match fs::read_to_string(template_file) {
            Ok(s) => match Tera::one_off(s.as_str(), context.clone(), config.autoescape) {
                // cool, we've been able to read the template file
                Ok(s) => {
                    // we have successfully rendered the template
                    write!(writer, "{}", s).unwrap_or_else(|e| {
                        log::error!("Unable to write rendered template to output: {}", e);
                        process::exit(1);
                    });
                    success.store(true, Ordering::SeqCst);
                }
                Err(e) => {
                    // rendering the template has failed
                    log::error!(
                        "Unable to render template file {}: {:?}",
                        template_file.display(),
                        e
                    );
                }
            },
            Err(e) => {
                // we weren't able to read the template file
                log::error!(
                    "Unable to read template file {}: {}",
                    template_file.display(),
                    e
                );
            }
        }
    }
    if !success.load(Ordering::SeqCst) {
        log::error!("Unable to successfully render any provided templates.");
        process::exit(1);
    }
}
fn render_template_files ( config : & RenderCommand , context : Context , writer : & mut Write ) { let success = AtomicBool :: new ( false ) ; for template_file in & config . template_files { log :: info ! ( " " template_file display ( ) ) ; match fs :: read_to_string ( template_file ) { Ok ( s ) => match Tera :: one_off ( s . as_str ( ) , context . clone ( ) , config . autoescape ) { // cool, we've been able to read the template file Ok ( s ) => { // we have successfully rendered the template write ! ( writer " " s ) . unwrap_or_else ( | e | { log :: error ! ( " " e ) ; process :: exit ( 1 ) ; } ) ; success . store ( true , Ordering :: SeqCst ) ; } Err ( e ) => { // rendering the template has failed log :: error ! ( " " template_file display ( ) e ) ; } } , Err ( e ) => { // we weren't able to read the template file log :: error ! ( " " template_file display ( ) e ) ; } } } if ! success . load ( Ordering :: SeqCst ) { log :: error ! ( " " ) ; process :: exit ( 1 ) ; } }
Render a list of template files from the configuration.
Render a list of template files from the configuration .
config
&RenderCommand
context
Context
writer
&mut Write
config
&RenderCommand
context
Context
writer
&mut Write