mirror of
https://github.com/twigphp/Twig.git
synced 2026-10-05 19:37:15 +00:00
Improve macro call performance
This commit is contained in:
@@ -53,6 +53,10 @@ final class MacroNamespace
|
||||
*/
|
||||
public function call(string $name, array $arguments, array $context, int $line, Source $source): string|Markup
|
||||
{
|
||||
if (null !== $macro = $this->getDeclared($name)) {
|
||||
return $macro->callLegacy($arguments, $source, $line);
|
||||
}
|
||||
|
||||
if (null === $macro = $this->resolve($name, $context)) {
|
||||
if (!str_starts_with($name, 'macro_') || null === $macro = $this->resolve($bareName = substr($name, \strlen('macro_')), $context)) {
|
||||
throw new RuntimeError(\sprintf('Macro "%s" is not defined in template "%s".', $name, $this->template->getTemplateName()), $line, $source);
|
||||
|
||||
Reference in New Issue
Block a user