Skip to content

Commit 9ec4a0d

Browse files
committed
emails/templates: Use .txt.j2 file extension
This enables editors to realize that this is a template file.
1 parent 3b12a0f commit 9ec4a0d

File tree

27 files changed

+8
-8
lines changed

27 files changed

+8
-8
lines changed

src/email.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ static EMAIL_ENV: LazyLock<Environment<'static>> = LazyLock::new(|| {
3232
let email_name = dir_name.to_str();
3333
let email_name = email_name.expect("Invalid UTF-8 in email template directory name");
3434

35-
// Load subject.txt file
36-
let subject_path = entry.path().join("subject.txt");
35+
// Load subject.txt.j2 file
36+
let subject_path = entry.path().join("subject.txt.j2");
3737
let subject_contents = std::fs::read_to_string(&subject_path)
3838
.expect(&format!("Failed to read subject template for {email_name}"));
39-
let filename = format!("{}/subject.txt", email_name);
39+
let filename = format!("{}/subject.txt.j2", email_name);
4040
env.add_template_owned(filename, subject_contents)
4141
.expect("Failed to add subject template");
4242

43-
// Load body.txt file
44-
let body_path = entry.path().join("body.txt");
43+
// Load body.txt.j2 file
44+
let body_path = entry.path().join("body.txt.j2");
4545
let body_contents = std::fs::read_to_string(&body_path)
4646
.expect(&format!("Failed to read body template for {email_name}"));
47-
let filename = format!("{}/body.txt", email_name);
47+
let filename = format!("{}/body.txt.j2", email_name);
4848
env.add_template_owned(filename, body_contents)
4949
.expect("Failed to add body template");
5050
}
@@ -70,8 +70,8 @@ impl EmailMessage {
7070
template_name: &str,
7171
context: impl Serialize,
7272
) -> Result<Self, minijinja::Error> {
73-
let subject = render_template(&format!("{}/subject.txt", template_name), &context)?;
74-
let body_text = render_template(&format!("{}/body.txt", template_name), context)?;
73+
let subject = render_template(&format!("{}/subject.txt.j2", template_name), &context)?;
74+
let body_text = render_template(&format!("{}/body.txt.j2", template_name), context)?;
7575

7676
Ok(EmailMessage { subject, body_text })
7777
}

0 commit comments

Comments
 (0)