Function mrml::parse_with_options
source · pub fn parse_with_options<T: AsRef<str>>(
input: T,
opts: Rc<ParserOptions>
) -> Result<Mjml, Error>Expand description
Function to parse a raw mjml template with some parsing options.
This function is just an alias to the Mjml::parse_with_options function.
You can specify the kind of loader mrml needs to use for loading the content of
mj-include elements.
You can take a look at the available loaders here.
use mrml::prelude::parse::ParserOptions;
use mrml::prelude::parse::memory_loader::MemoryIncludeLoader;
use std::rc::Rc;
let options = Rc::new(ParserOptions {
include_loader: Box::new(MemoryIncludeLoader::default()),
});
match mrml::parse_with_options("<mjml><mj-head /><mj-body /></mjml>", options) {
Ok(_) => println!("Success!"),
Err(err) => eprintln!("Something went wrong: {err:?}"),
}