Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Parser
private $importedSymbols;
private $traits;
private $embeddedTemplates = [];
private int $nextEmbedIndex = 1;
private $varNameSalt = 0;
private $ignoreUnknownTwigCallables = false;
private ExpressionParsers $parsers;
Expand Down Expand Up @@ -83,6 +84,12 @@ public function parse(TokenStream $stream, $test = null, bool $dropNeedle = fals
{
$vars = get_object_vars($this);
unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser'], $vars['reservedMacroNames'], $vars['varNameSalt']);

// restore on root modules only
if (0 < \count($this->stack)) {
unset($vars['nextEmbedIndex']);
Comment thread
itsalmostchristmas marked this conversation as resolved.
Outdated
}

$this->stack[] = $vars;

// node visitors
Expand Down Expand Up @@ -319,7 +326,7 @@ public function hasTraits(): bool
*/
public function embedTemplate(ModuleNode $template)
{
$template->setIndex(mt_rand());
$template->setIndex($this->nextEmbedIndex++);

$this->embeddedTemplates[] = $template;
}
Expand Down