Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/View/Antlers/Language/Runtime/GlobalRuntimeState.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public static function resetGlobalState()
self::$tracedRuntimeAssignments = [];
self::$traceTagAssignments = false;
self::$environmentId = StringUtilities::uuidv4();
self::$interpolatedVariables = [];
self::$yieldCount = 0;
self::$yieldStacks = [];
self::$abandonedNodes = [];
Expand Down
22 changes: 22 additions & 0 deletions tests/View/StateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests\View;

use Statamic\View\Antlers\Language\Runtime\GlobalRuntimeState;
use Statamic\View\Antlers\Language\Utilities\StringUtilities;
use Tests\FakesContent;
use Tests\FakesViews;
Expand Down Expand Up @@ -50,6 +51,27 @@ public function test_tag_state_is_cleared_between_responses()
$this->assertSame($expected, $resultThree);
}

public function test_interpolated_variables_are_cleared_between_responses()
{
$this->withFakeViews();
$this->viewShouldReturnRaw('layout', '{{ template_content }}');
$this->viewShouldReturnRaw('default', '{{ link to="/pages/{slug}" }} {{ num | add:{num} }}');

$this->createPage('home', [
'with' => [
'title' => 'Home Page',
'num' => 3,
'template' => 'default',
],
]);

$this->assertSame('/pages/home 6', $this->getResponseContent('/home'));
$this->assertSame([], GlobalRuntimeState::$interpolatedVariables);

$this->assertSame('/pages/home 6', $this->getResponseContent('/home'));
$this->assertSame([], GlobalRuntimeState::$interpolatedVariables);
}

protected function getResponseContent($uri)
{
$response = $this->get($uri)->assertStatus(200);
Expand Down
Loading