email: fix unable to override templates in custom directory#7905
Conversation
Introduce a `customDir` variable to store the custom template directory path, improving code readability and reducing redundancy in both `web.go` and `email.go`. This change ensures that the custom directory is consistently referenced throughout the configuration.
|
Thanks for the PR! Will review and test sometime soon. |
Thank you for your reply. Since English is not my native language, I used Chinese. If you need English or more help, please contact me. I will be happy to help you. |
Sorry for taking a while, looking at it now. And no worries I can speak Chinese, it's just for the sake of others watching/looking back to this PR, we only try to communicate in English (and I will update your PR title to reflect that upon merging). |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7905 +/- ##
==========================================
- Coverage 15.28% 10.73% -4.55%
==========================================
Files 106 209 +103
Lines 13864 28867 +15003
==========================================
+ Hits 2119 3099 +980
- Misses 11465 25477 +14012
- Partials 280 291 +11 |
Co-authored-by: Joe Chen <jc@unknwon.io>
|
The 0.13.3 has been released that includes this patch. |
Co-authored-by: Joe Chen <jc@unknwon.io>
Describe the pull request
在
cusmtor/templates/mail目录下放置tmpl文件,无法被正确读取。Checklist
Test plan
FIleSystem在加载文件时,把
customer+name目录拼接,然后在该目录下寻找文件是否存在,不存在则使用系统默认模板。这个在
web系统工作起来没有问题,但是在email系统工作旧出现了问题。因为email中,传入的custorm是custorm/templates/mail,而FileSystem检索到的文件名是mail/xxx.tmpl,两者相加得到custorm/templates/mail/mail/xxx.tmpl,这将导致文件不存在。因为文件实际的路径是custorm/templates/mail/xxx.tmpl。我修复了传入调用
NewTemplateFileSystem时传入的curstomDir参数,问题得到了解决。