refactor: 移除邮件模板向后兼容代码

- 移除旧版 {{#if variable}}...{{/if}} 条件语法支持
- 仅保留 Mustache 标准语法({{#variable}} 和 {{^variable}})
This commit is contained in:
2026-01-22 13:16:22 +08:00
parent c0fa3d2352
commit f603edde0b

View File

@@ -348,17 +348,6 @@ function argon_replace_placeholders($template, $vars, $escape = false) {
return ''; return '';
}, $template); }, $template);
// 处理旧版条件语句 {{#if variable}}...{{/if}}(向后兼容)
$template = preg_replace_callback('/\{\{#if\s+(\w+)\}\}(.*?)\{\{\/if\}\}/s', function($matches) use ($vars) {
$var_name = $matches[1];
$content = $matches[2];
// 如果变量存在且不为空,返回内容,否则返回空字符串
if (isset($vars[$var_name]) && !empty($vars[$var_name])) {
return $content;
}
return '';
}, $template);
// 替换普通占位符 // 替换普通占位符
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if ($escape && !in_array($key, array('theme_color', 'blog_url', 'post_url', 'comment_url', 'reset_url', 'login_url', 'feedback_manage_url', 'feedback_view_url'))) { if ($escape && !in_array($key, array('theme_color', 'blog_url', 'post_url', 'comment_url', 'reset_url', 'login_url', 'feedback_manage_url', 'feedback_view_url'))) {