\n"; $html1 = 'test'; $parser = new HtmlParser(); $doc1 = $parser->parse($html1); $body1 = $doc1->getChildren()[0]; foreach ($body1->getChildren() as $child) { if ($child instanceof \App\Framework\View\Dom\ElementNode && $child->getTagName() === 'a') { $a1 = $child; break; } } if (isset($a1)) { $href1 = $a1->getAttribute('href'); echo " href attribute: [$href1]\n"; $decoded1 = html_entity_decode($href1, ENT_QUOTES | ENT_HTML5, 'UTF-8'); echo " decoded: [$decoded1]\n"; echo " contains {{: " . (str_contains($decoded1, '{{') ? 'YES' : 'NO') . "\n\n"; } else { echo " ERROR: Could not find element\n\n"; } // Test 2: Parse foreach with placeholder echo "Test 2: Parse
  • \n"; $html2 = '
  • test
  • '; $doc2 = $parser->parse($html2); $body2 = $doc2->getChildren()[0]; foreach ($body2->getChildren() as $child) { if ($child instanceof \App\Framework\View\Dom\ElementNode && $child->getTagName() === 'li') { $li2 = $child; break; } } if (isset($li2)) { echo " LI foreach: " . ($li2->getAttribute('foreach') ?? 'NULL') . "\n"; foreach ($li2->getChildren() as $child) { if ($child instanceof \App\Framework\View\Dom\ElementNode && $child->getTagName() === 'a') { $a2 = $child; break; } } if (isset($a2)) { $href2 = $a2->getAttribute('href'); echo " href attribute: [$href2]\n"; $decoded2 = html_entity_decode($href2, ENT_QUOTES | ENT_HTML5, 'UTF-8'); echo " decoded: [$decoded2]\n"; echo " contains {{: " . (str_contains($decoded2, '{{') ? 'YES' : 'NO') . "\n\n"; } else { echo " ERROR: Could not find element\n\n"; } } else { echo " ERROR: Could not find
  • element\n\n"; } // Test 3: Test ForTransformer processing echo "Test 3: Test ForTransformer with mock data\n"; $container = new DefaultContainer(); $transformer = new ForTransformer($container); $context = new RenderContext( template: 'test', metaData: [], data: [ 'items' => [ ['url' => '/home', 'name' => 'Home'], ['url' => '/about', 'name' => 'About'], ] ], controllerClass: null ); $html3 = '
  • test
  • '; $doc3 = $parser->parse($html3); $transformer->transform($doc3, $context); echo " After transformation:\n"; $body3 = $doc3->getChildren()[0]; $children3 = $body3->getChildren(); echo " Children count: " . count($children3) . "\n"; foreach ($children3 as $idx => $child) { if ($child instanceof \App\Framework\View\Dom\ElementNode) { foreach ($child->getChildren() as $grandChild) { if ($grandChild instanceof \App\Framework\View\Dom\ElementNode && $grandChild->getTagName() === 'a') { $href3 = $grandChild->getAttribute('href'); echo " Child $idx href: [$href3]\n"; break; } } } } echo "\n=== Tests Complete ===\n";