|
2 | 2 |
|
3 | 3 | namespace Tests\Antlers\Runtime; |
4 | 4 |
|
| 5 | +use Statamic\View\Antlers\Language\Runtime\GlobalRuntimeState; |
| 6 | +use Statamic\View\Antlers\Language\Runtime\NodeProcessor; |
5 | 7 | use Statamic\View\Antlers\Language\Utilities\StringUtilities; |
6 | 8 | use Tests\Antlers\ParserTestCase; |
| 9 | +use Tests\FakesViews; |
7 | 10 |
|
8 | 11 | class NoparseTest extends ParserTestCase |
9 | 12 | { |
| 13 | + use FakesViews; |
| 14 | + |
10 | 15 | public function test_noparse_ignores_braces_entirely() |
11 | 16 | { |
12 | 17 | $template = <<<'EOT' |
@@ -142,4 +147,39 @@ public function test_multiple_noparse_regions() |
142 | 147 |
|
143 | 148 | $this->assertSame($expected, StringUtilities::normalizeLineEndings(trim($this->renderString($template, ['title' => 'the title'])))); |
144 | 149 | } |
| 150 | + |
| 151 | + public function test_noparse_in_nested_partials_renders_correctly() |
| 152 | + { |
| 153 | + $template = <<<'EOT' |
| 154 | + {{ partial:partial_a }} |
| 155 | + {{ partial:partial_a }} |
| 156 | + {{ noparse }}inside noparse{{ /noparse }} |
| 157 | + {{ /partial:partial_a }} |
| 158 | + {{ /partial:partial_a }} |
| 159 | +
|
| 160 | + {{ partial:partial_a }} |
| 161 | + {{ partial:partial_a }} |
| 162 | + {{ noparse }}inside noparse{{ /noparse }} |
| 163 | + {{ /partial:partial_a }} |
| 164 | + {{ /partial:partial_a }} |
| 165 | +
|
| 166 | + {{ partial:partial_a }} |
| 167 | + {{ partial:partial_a }} |
| 168 | + {{ noparse }}inside noparse{{ /noparse }} |
| 169 | + {{ /partial:partial_a }} |
| 170 | + {{ /partial:partial_a }} |
| 171 | +EOT; |
| 172 | + |
| 173 | + GlobalRuntimeState::$peekCallbacks[] = function ($processor, $nodes) { |
| 174 | + NodeProcessor::$break = true; |
| 175 | + }; |
| 176 | + |
| 177 | + $this->withFakeViews(); |
| 178 | + $this->viewShouldReturnRaw('partial_a', '{{ slot }}'); |
| 179 | + |
| 180 | + $actual = StringUtilities::normalizeLineEndings(trim($this->renderString($template))); |
| 181 | + |
| 182 | + $occurrences = substr_count($actual, 'inside noparse'); |
| 183 | + $this->assertEquals(3, $occurrences, "Expected 'inside noparse' to appear exactly 3 times"); |
| 184 | + } |
145 | 185 | } |
0 commit comments