Function nya::run[][src]

pub fn run(
    middleware: Vec<MiddlewareFunction>,
    source: Option<&str>,
    destination: Option<&str>
) -> Result<Vec<SimpleFile>, Error>

Runs a middleware chain.

Reads a file from the source argument (default is the current directory), runs the collected files through the provided middleware chain, and then writes the result to the destination argument (default is _site). Both arguments have to be provided, although they accept an Option, so you can pass in None if you want the defaults to apply. Returns a Result<Vec<SimpleFile>, std::io::Error>.

Example

let func = nya::create_middleware(|files: &mut Vec<nya::SimpleFile>| {
    let file = &mut files[0];
    file.content = "haha hello".to_string();
});

let result = nya::run(vec![func], Some("fixtures/example"), None);
if let Ok(r) = result {
    println!("Success!");
}