email: pass template_dir in config
This commit is contained in:
parent
8657c1198d
commit
cd7a894334
5 changed files with 66 additions and 49 deletions
|
|
@ -37,13 +37,12 @@ pub enum Error {
|
|||
|
||||
const TEMPLATE_EXT: &str = ".mjml.tera";
|
||||
|
||||
pub fn render_template<C: Serialize>(name: &str, content: C) -> Result<String, Error> {
|
||||
let base_dir = if cfg!(debug_assertions) {
|
||||
format!("{}/templates", env!("CARGO_MANIFEST_DIR"))
|
||||
} else {
|
||||
"./email-templates".into()
|
||||
};
|
||||
let templates = format!("{base_dir}/**/*{TEMPLATE_EXT}",);
|
||||
pub fn render_template<C: Serialize>(
|
||||
name: &str,
|
||||
template_dir: &str,
|
||||
content: C,
|
||||
) -> Result<String, Error> {
|
||||
let templates = format!("{template_dir}/**/*{TEMPLATE_EXT}");
|
||||
|
||||
// Initialize tera templates
|
||||
let tera = Tera::new(&templates)?;
|
||||
|
|
@ -75,6 +74,7 @@ pub enum Transport {
|
|||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Config {
|
||||
pub template_dir: String,
|
||||
pub from: String,
|
||||
pub transport: Transport,
|
||||
pub host: String,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue