1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#[macro_use]
extern crate pest_derive;

pub mod ast;
pub mod parser;
pub mod processor;

#[cfg(test)]
mod tests;

use crate::parser::parse;
use crate::processor::process;
use std::collections::HashMap;

pub fn generate<F>(
    content: &str,
    separator: &str,
    variables: HashMap<String, String>,
    on_import: F,
) -> Result<String, String>
where
    F: FnMut(&str) -> Result<String, String>,
{
    let ast = parse(content)?;
    process(&ast, separator, variables, on_import)
}