38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
namespace LMS.Common.Templates
|
||
{
|
||
public class EmailTemplateService()
|
||
{
|
||
/// <summary>
|
||
/// 注册邮件模板
|
||
/// </summary>
|
||
public const string RegisterHtmlTemplates = """
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<body>
|
||
<h1>LMS Registration Code</h1>
|
||
<p>Hi there,</p>
|
||
<p>Your code is <strong>{RegisterCode}</strong></p>
|
||
<p>The code is valid for 10 minutes, if it is not you, please ignore it.</p>
|
||
</body>
|
||
</html>
|
||
""";
|
||
|
||
|
||
/// <summary>
|
||
/// 替换模板的占位符
|
||
/// </summary>
|
||
/// <param name="template"></param>
|
||
/// <param name="parameters"></param>
|
||
/// <returns></returns>
|
||
public static string ReplaceTemplate(string template, Dictionary<string, string> parameters)
|
||
{
|
||
// 替换占位符
|
||
foreach (var param in parameters)
|
||
{
|
||
template = template.Replace($"{{{param.Key}}}", param.Value);
|
||
}
|
||
return template;
|
||
}
|
||
}
|
||
}
|