summaryrefslogtreecommitdiff
path: root/lib/mail/mailer.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-07-08 11:23:40 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-07-08 11:23:40 +0000
commitb84621f9b2b7161a5ad4f0b194264e9df3e65dbf (patch)
treece5ec30b3d1e5104a3a2d942c71973779436783b /lib/mail/mailer.ts
parent97936ddf280c56a4f122dedcb8dc389d0d2e63a2 (diff)
(대표님) 20250708 미반영분 커밋
Diffstat (limited to 'lib/mail/mailer.ts')
-rw-r--r--lib/mail/mailer.ts146
1 files changed, 102 insertions, 44 deletions
diff --git a/lib/mail/mailer.ts b/lib/mail/mailer.ts
index 61201e99..0387d7dd 100644
--- a/lib/mail/mailer.ts
+++ b/lib/mail/mailer.ts
@@ -23,54 +23,96 @@ function registerHandlebarsHelpers() {
return i18next.t(key, options.hash || {});
});
- // eq 헬퍼 등록 - 두 값을 비교 (블록 헬퍼)
- handlebars.registerHelper('eq', function(a: any, b: any, options: any) {
- if (a === b) {
- return options.fn(this);
- } else {
- return options.inverse(this);
+ // eq 헬퍼 등록 - 인라인과 블록 헬퍼 둘 다 지원
+ handlebars.registerHelper('eq', function(a: any, b: any, options?: any) {
+ const result = a === b;
+
+ // 블록 헬퍼로 사용된 경우 (options가 있고 fn 함수가 있는 경우)
+ if (options && typeof options.fn === 'function') {
+ if (result) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
}
+
+ // 인라인 헬퍼로 사용된 경우
+ return result;
});
- // 기타 유용한 헬퍼들
- handlebars.registerHelper('ne', function(a: any, b: any, options: any) {
- if (a !== b) {
- return options.fn(this);
- } else {
- return options.inverse(this);
+ // ne 헬퍼 - 인라인과 블록 헬퍼 둘 다 지원
+ handlebars.registerHelper('ne', function(a: any, b: any, options?: any) {
+ const result = a !== b;
+
+ if (options && typeof options.fn === 'function') {
+ if (result) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
}
+
+ return result;
});
- handlebars.registerHelper('gt', function(a: any, b: any, options: any) {
- if (a > b) {
- return options.fn(this);
- } else {
- return options.inverse(this);
+ // gt 헬퍼 - 인라인과 블록 헬퍼 둘 다 지원
+ handlebars.registerHelper('gt', function(a: any, b: any, options?: any) {
+ const result = a > b;
+
+ if (options && typeof options.fn === 'function') {
+ if (result) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
}
+
+ return result;
});
- handlebars.registerHelper('gte', function(a: any, b: any, options: any) {
- if (a >= b) {
- return options.fn(this);
- } else {
- return options.inverse(this);
+ // gte 헬퍼 - 인라인과 블록 헬퍼 둘 다 지원
+ handlebars.registerHelper('gte', function(a: any, b: any, options?: any) {
+ const result = a >= b;
+
+ if (options && typeof options.fn === 'function') {
+ if (result) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
}
+
+ return result;
});
- handlebars.registerHelper('lt', function(a: any, b: any, options: any) {
- if (a < b) {
- return options.fn(this);
- } else {
- return options.inverse(this);
+ // lt 헬퍼 - 인라인과 블록 헬퍼 둘 다 지원
+ handlebars.registerHelper('lt', function(a: any, b: any, options?: any) {
+ const result = a < b;
+
+ if (options && typeof options.fn === 'function') {
+ if (result) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
}
+
+ return result;
});
- handlebars.registerHelper('lte', function(a: any, b: any, options: any) {
- if (a <= b) {
- return options.fn(this);
- } else {
- return options.inverse(this);
+ // lte 헬퍼 - 인라인과 블록 헬퍼 둘 다 지원
+ handlebars.registerHelper('lte', function(a: any, b: any, options?: any) {
+ const result = a <= b;
+
+ if (options && typeof options.fn === 'function') {
+ if (result) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
}
+
+ return result;
});
// and 헬퍼 - 모든 조건이 true인지 확인 (블록 헬퍼)
@@ -78,12 +120,17 @@ function registerHandlebarsHelpers() {
// 마지막 인자는 Handlebars 옵션
const options = args[args.length - 1];
const values = args.slice(0, -1);
+ const result = values.every(Boolean);
- if (values.every(Boolean)) {
- return options.fn(this);
- } else {
- return options.inverse(this);
+ if (typeof options.fn === 'function') {
+ if (result) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
}
+
+ return result;
});
// or 헬퍼 - 하나라도 true인지 확인 (블록 헬퍼)
@@ -91,21 +138,32 @@ function registerHandlebarsHelpers() {
// 마지막 인자는 Handlebars 옵션
const options = args[args.length - 1];
const values = args.slice(0, -1);
+ const result = values.some(Boolean);
- if (values.some(Boolean)) {
- return options.fn(this);
- } else {
- return options.inverse(this);
+ if (typeof options.fn === 'function') {
+ if (result) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
}
+
+ return result;
});
// not 헬퍼 - 값 반전 (블록 헬퍼)
handlebars.registerHelper('not', function(value: any, options: any) {
- if (!value) {
- return options.fn(this);
- } else {
- return options.inverse(this);
+ const result = !value;
+
+ if (typeof options.fn === 'function') {
+ if (result) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
}
+
+ return result;
});
// formatDate 헬퍼 - 날짜 포맷팅