Skip to content

Commit

Permalink
Bridge: compatibility with Latte 2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 22, 2021
1 parent 7794de6 commit c3c8bf0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Bridges/Nette/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand All @@ -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 [
Expand Down

0 comments on commit c3c8bf0

Please sign in to comment.