summaryrefslogtreecommitdiff
path: root/php/templates.php
diff options
context:
space:
mode:
authorConnor Thomson <blumatrikz@gmail.com>2026-09-18 17:23:39 -0700
committerConnor Thomson <blumatrikz@gmail.com>2026-09-18 17:23:39 -0700
commit94a6551bafd51deb2bfae144336689eb0472abf6 (patch)
tree103db6511e06a43dbc90fc26b89ded9ca519a3d3 /php/templates.php
Upload files from test.gnufault.org
Diffstat (limited to 'php/templates.php')
-rw-r--r--php/templates.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/php/templates.php b/php/templates.php
new file mode 100644
index 0000000..4ead3f8
--- /dev/null
+++ b/php/templates.php
@@ -0,0 +1,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;
+}
+
+?>