From c3c8bf05fe5fc79dcb6e215789ba8200025c5a2e Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 23 Jan 2021 00:09:37 +0100 Subject: [PATCH] Bridge: compatibility with Latte 2.10 --- src/Bridges/Nette/Bridge.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bridges/Nette/Bridge.php b/src/Bridges/Nette/Bridge.php index 2fe97b23d..bfb4f4687 100644 --- a/src/Bridges/Nette/Bridge.php +++ b/src/Bridges/Nette/Bridge.php @@ -49,8 +49,8 @@ public static function renderLatteError(?\Throwable $e): ?array ]; } elseif ($e && strpos($file = $e->getFile(), '.latte--')) { - $lines = file($file); - if (preg_match('#// source: (\S+\.latte)#', $lines[1], $m) && @is_file($m[1])) { // @ - may trigger error + $lines = file($file, FILE_IGNORE_NEW_LINES); + if (preg_match('#/(?:/|\*\*) source: (\S+\.latte)#', $lines[1] ?: $lines[4], $m) && @is_file($m[1])) { // @ - may trigger error $templateFile = $m[1]; $templateLine = $e->getLine() && preg_match('#/\* line (\d+) \*/#', $lines[$e->getLine() - 1], $m) ? (int) $m[1] : 0; return [ @@ -71,7 +71,7 @@ public static function renderLatteUnknownMacro(?\Throwable $e): ?array if ( $e instanceof Latte\CompileException && @is_file($e->sourceName) // @ - may trigger error - && (preg_match('#Unknown macro (\{\w+)\}, did you mean (\{\w+)\}\?#A', $e->getMessage(), $m) + && (preg_match('#Unknown (?:macro|tag) (\{\w+)\}, did you mean (\{\w+)\}\?#A', $e->getMessage(), $m) || preg_match('#Unknown attribute (n:\w+), did you mean (n:\w+)\?#A', $e->getMessage(), $m)) ) { return [