Enhance Template Processing and Cleanup: Updated the ImportHtmlTemplates command to skip additional custom tokens during HTML processing and added a cleanup step to remove leftover tokens from the data array. Improved the TemplateService to replace legacy tokens in HTML, ensuring better template integrity during imports.

This commit is contained in:
Ümit Tunç
2025-12-29 09:39:21 +03:00
parent f4603456b1
commit 9d601cafda
2 changed files with 21 additions and 2 deletions
+13 -2
View File
@@ -268,8 +268,8 @@ class ImportHtmlTemplates extends Command
if (in_array(strtolower($parent->nodeName), ['script', 'style', 'noscript', 'iframe'])) continue;
$textContent = trim($textNode->textContent);
// Özel tokenlarımızı atla
if (str_contains($textContent, '___SPECIAL_') || str_contains($textContent, '___SETTING_')) continue;
// Özel tokenlarımızı atla (___SPECIAL_, ___SETTING_, ___CUSTOM_)
if (str_contains($textContent, '___SPECIAL_') || str_contains($textContent, '___SETTING_') || str_contains($textContent, '___CUSTOM_')) continue;
if (str_starts_with($textContent, '{') && str_ends_with($textContent, '}')) continue;
if (mb_strlen($textContent) < 2) continue;
@@ -297,6 +297,17 @@ class ImportHtmlTemplates extends Command
$html = str_replace('___CUSTOM_LANGUAGE___', '{custom.language-selector}', $html);
$html = str_replace('___SETTING_LANGUAGES___', '{custom.language-selector}', $html);
// Clean default_data from any leftover tokens
foreach ($data as $key => $value) {
if (is_string($value) && (
str_contains($value, '___CUSTOM_') ||
str_contains($value, '___SPECIAL_') ||
str_contains($value, '___SETTING_')
)) {
unset($data[$key]);
}
}
return ['html' => $html, 'data' => $data];
}