blob: 4ead3f8b87e3392c1548723dde7eed39eb70db79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<?php
function render_component(string $componentPath): string {
ob_start();
include($componentPath);
return ob_get_clean();
}
function template_process(string $template, array $components = []): string {
$html = file_get_contents($template);
foreach ($components as $placeholder => $componentPath) {
$injectedContent = render_component($componentPath);
$html = str_replace($placeholder, $injectedContent, $html);
}
return $html;
}
?>
|