diff --git a/application/Espo/Core/Htmlizer/Htmlizer.php b/application/Espo/Core/Htmlizer/Htmlizer.php
index 4e025101b4..f51dfd423b 100644
--- a/application/Espo/Core/Htmlizer/Htmlizer.php
+++ b/application/Espo/Core/Htmlizer/Htmlizer.php
@@ -126,6 +126,7 @@ class Htmlizer
* @param ?string $cacheId @deprecated To be skipped..
* @param ?array $additionalData Data will be passed to the template.
* @param bool $skipLinks Do not process related records.
+ * @throws Error
*/
public function render(
?Entity $entity,
@@ -148,8 +149,15 @@ class Htmlizer
throw new Error("Template compile error.");
}
+ /**
+ * @var \Closure|false $renderer
+ */
$renderer = LightnCandy::prepare($code);
+ if ($renderer === false) {
+ throw new Error("Template compile error.");
+ }
+
if ($additionalData === null) {
$additionalData = [];
}
@@ -178,7 +186,6 @@ class Htmlizer
$data['__log'] = $this->log;
$data['__entityType'] = $entity ? $entity->getEntityType() : null;
- /** @phpstan-ignore-next-line */
$html = $renderer($data);
$html = str_replace('?entryPoint=attachment&', '?entryPoint=attachment&', $html);