Skip to content

Commit c3c8bf0

Browse files
committed
Bridge: compatibility with Latte 2.10
1 parent 7794de6 commit c3c8bf0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Bridges/Nette/Bridge.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public static function renderLatteError(?\Throwable $e): ?array
4949
];
5050

5151
} elseif ($e && strpos($file = $e->getFile(), '.latte--')) {
52-
$lines = file($file);
53-
if (preg_match('#// source: (\S+\.latte)#', $lines[1], $m) && @is_file($m[1])) { // @ - may trigger error
52+
$lines = file($file, FILE_IGNORE_NEW_LINES);
53+
if (preg_match('#/(?:/|\*\*) source: (\S+\.latte)#', $lines[1] ?: $lines[4], $m) && @is_file($m[1])) { // @ - may trigger error
5454
$templateFile = $m[1];
5555
$templateLine = $e->getLine() && preg_match('#/\* line (\d+) \*/#', $lines[$e->getLine() - 1], $m) ? (int) $m[1] : 0;
5656
return [
@@ -71,7 +71,7 @@ public static function renderLatteUnknownMacro(?\Throwable $e): ?array
7171
if (
7272
$e instanceof Latte\CompileException
7373
&& @is_file($e->sourceName) // @ - may trigger error
74-
&& (preg_match('#Unknown macro (\{\w+)\}, did you mean (\{\w+)\}\?#A', $e->getMessage(), $m)
74+
&& (preg_match('#Unknown (?:macro|tag) (\{\w+)\}, did you mean (\{\w+)\}\?#A', $e->getMessage(), $m)
7575
|| preg_match('#Unknown attribute (n:\w+), did you mean (n:\w+)\?#A', $e->getMessage(), $m))
7676
) {
7777
return [

0 commit comments

Comments
 (0)