Skip to content

Commit 8c8c2b1

Browse files
committed
emails/templates: Use .txt.j2 file extension
This enables editors to realize that this is a template file.
1 parent 61e1a96 commit 8c8c2b1

File tree

25 files changed

+12
-10
lines changed

25 files changed

+12
-10
lines changed

src/email.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,30 @@ static EMAIL_ENV: LazyLock<Environment<'static>> = LazyLock::new(|| {
2626
.to_str()
2727
.expect("Invalid email directory name");
2828

29-
// Find subject.txt file
30-
let filename = format!("{}/subject.txt", email_name);
29+
// Find subject.txt.j2 file
30+
let filename = format!("{}/subject.txt.j2", email_name);
3131

3232
let subject_file = TEMPLATE_DIR
3333
.get_file(&filename)
34-
.expect("Missing subject.txt");
34+
.expect("Missing subject.txt.j2");
3535

3636
let subject_contents = subject_file
3737
.contents_utf8()
38-
.expect("Invalid UTF-8 in subject.txt");
38+
.expect("Invalid UTF-8 in subject.txt.j2");
3939

4040
env.add_template_owned(filename, subject_contents)
4141
.expect("Failed to add subject template");
4242

43-
// Find body.txt file
44-
let filename = format!("{}/body.txt", email_name);
43+
// Find body.txt.j2 file
44+
let filename = format!("{}/body.txt.j2", email_name);
4545

46-
let body_file = TEMPLATE_DIR.get_file(&filename).expect("Missing body.txt");
46+
let body_file = TEMPLATE_DIR
47+
.get_file(&filename)
48+
.expect("Missing body.txt.j2");
4749

4850
let body_contents = body_file
4951
.contents_utf8()
50-
.expect("Invalid UTF-8 in body.txt");
52+
.expect("Invalid UTF-8 in body.txt.j2");
5153

5254
env.add_template_owned(filename, body_contents)
5355
.expect("Failed to add body template");
@@ -74,8 +76,8 @@ impl EmailMessage {
7476
template_name: &str,
7577
context: impl Serialize,
7678
) -> Result<Self, minijinja::Error> {
77-
let subject = render_template(&format!("{}/subject.txt", template_name), &context)?;
78-
let body_text = render_template(&format!("{}/body.txt", template_name), context)?;
79+
let subject = render_template(&format!("{}/subject.txt.j2", template_name), &context)?;
80+
let body_text = render_template(&format!("{}/body.txt.j2", template_name), context)?;
7981

8082
Ok(EmailMessage { subject, body_text })
8183
}

0 commit comments

Comments
 (0)