replacer 0.4.0

Creating compilable Rust source code templates.
Documentation

replacer

Creating compilable Rust source code templates.

Example

Rust source template:

fn main() {
	println!("Hello $$replace_with_string$$!");

    let some_type = <replacer::rust_type!(replace_with_type; String;)>::new();
}

Rust script to parse the template:

use replacer::{rule::{StringRule, TypeRule}, TemplateBuilder};

fn main() {
    let template = TemplateBuilder::new()
        .rule(StringRule::new("replace_with_string", "world").unwrap())
        .rule(TypeRule::new("replace_with_type", "Vec").unwrap())
        .build();

    println!(template.apply(include_str!(SOURCE_TEMPLATE_FROM_ABOVE)).unwrap());
}

Rust template that will be printed:

fn main() {
	println!("Hello world!");

	let some_type = <Vec>::new();
}