get(ForStringProcessor::class);
// Test HTML with foreach attribute - EXACTLY like in ML Dashboard
$html = <<<'HTML'
| Model Name |
Version |
Status |
| {{ $model['model_name'] }} |
{{ $model['version'] }} |
{{ $model['status'] }} |
HTML;
// Test data with 2 models
$data = [
'models' => [
[
'model_name' => 'fraud-detector',
'version' => '1.0.0',
'status' => 'healthy'
],
[
'model_name' => 'spam-classifier',
'version' => '2.0.0',
'status' => 'degraded'
],
]
];
// Create render context
$context = new RenderContext(
template: 'test',
metaData: new MetaData('test', 'test'),
data: $data,
controllerClass: null
);
echo "=== ORIGINAL HTML ===\n";
echo $html . "\n\n";
echo "=== PROCESSING WITH ForStringProcessor ===\n";
$result = $forStringProcessor->process($html, $context);
echo "=== PROCESSED HTML ===\n";
echo $result . "\n\n";
echo "=== VERIFICATION ===\n";
if (str_contains($result, 'foreach=')) {
echo "❌ PROBLEM: foreach attribute still present\n";
} else {
echo "✅ Good: foreach attribute removed\n";
}
if (str_contains($result, '{{ $model')) {
echo "❌ PROBLEM: Placeholders not replaced\n";
} else {
echo "✅ Good: Placeholders replaced\n";
}
if (str_contains($result, 'fraud-detector')) {
echo "✅ Good: Model data found in output\n";
} else {
echo "❌ PROBLEM: Model data NOT found in output\n";
}
if (str_contains($result, 'spam-classifier')) {
echo "✅ Good: Second model data found in output\n";
} else {
echo "❌ PROBLEM: Second model data NOT found in output\n";
}
// Count rows
$rowCount = substr_count($result, '');
echo "\nGenerated $rowCount
elements (expected: 3 - 1 header + 2 data rows)\n";