pub fn verify_template_parameters(
    template: String,
    parameters: &HashMap<String, String>,
) -> Result<String, HttpResponse> {
    if parameters.len() != 0 {
        info!("Got parameters: {:?}", parameters);
    }
    // Create a new handlebar instance and enable strict mode to prevent missing or malformed arguments
    let mut handlebars = Handlebars::new();
    handlebars.set_strict_mode(true);

    // Check the template for render errors with the current parameter
    let result = handlebars.render_template(&template, parameters);
    match result {
        Err(error) => {
            warn!(
                "Error rendering command with params: {:?}. Error: {:?}",
                parameters, error
            );
            Err(HttpResponse::build(StatusCode::BAD_REQUEST).json(format!("{:?}", error)))
        }
        Ok(result) => {
            if parameters.len() != 0 {
                info!("Template renders properly: {}", result);
            }
            Ok(result)
        }
    }
}
/// Verify that the template renders with the given parameters
Verify that the template renders with the given parameters
Verify that the template renders with the given parameters
pub fn verify_template_parameters(
    template: String,
    parameters: &HashMap<String, String>,
) -> Result<String, HttpResponse> {
    if parameters.len() != 0 {
        info!("Got parameters: {:?}", parameters);
    }
    // Create a new handlebar instance and enable strict mode to prevent missing or malformed arguments
    let mut handlebars = Handlebars::new();
    handlebars.set_strict_mode(true);
    // Check the template for render errors with the current parameter
    let result = handlebars.render_template(&template, parameters);
    match result {
        Err(error) => {
            warn!(
                "Error rendering command with params: {:?}. Error: {:?}",
                parameters, error
            );
            Err(HttpResponse::build(StatusCode::BAD_REQUEST).json(format!("{:?}", error)))
        }
        Ok(result) => {
            if parameters.len() != 0 {
                info!("Template renders properly: {}", result);
            }
            Ok(result)
        }
    }
}
pub fn verify_template_parameters ( template : String , parameters : & HashMap < String , String > , ) -> Result < String , HttpResponse > { if parameters . len ( ) != 0 { info ! ( " " parameters ) ; } // Create a new handlebar instance and enable strict mode to prevent missing or malformed arguments let mut handlebars = Handlebars :: new ( ) ; handlebars . set_strict_mode ( true ) ; // Check the template for render errors with the current parameter let result = handlebars . render_template ( & template , parameters ) ; match result { Err ( error ) => { warn ! ( " " parameters error ) ; Err ( HttpResponse :: build ( StatusCode :: BAD_REQUEST ) . json ( format ! ( " " error ) ) ) } Ok ( result ) => { if parameters . len ( ) != 0 { info ! ( " " result ) ; } Ok ( result ) } } }
Verify that the template renders with the given parameters
Verify that the template renders with the given parameters
template
String
parameters
&HashMap<String, String>
template
String
parameters
&HashMap<String, String>