aboutsummaryrefslogtreecommitdiff
path: root/src/View
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2023-05-31 20:58:43 -0500
committerChristian Cleberg <hello@cleberg.net>2023-05-31 20:58:43 -0500
commit468bc55ada06979e53b1d03b040b2dfe6beaf017 (patch)
tree472b23c050ab8ce7d1ae1cab30bcb37ebfe031e5 /src/View
downloadhn-468bc55ada06979e53b1d03b040b2dfe6beaf017.tar.gz
hn-468bc55ada06979e53b1d03b040b2dfe6beaf017.tar.bz2
hn-468bc55ada06979e53b1d03b040b2dfe6beaf017.zip
initial commit
Diffstat (limited to 'src/View')
-rw-r--r--src/View/class-template.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/View/class-template.php b/src/View/class-template.php
new file mode 100644
index 0000000..ea75648
--- /dev/null
+++ b/src/View/class-template.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace HN\View;
+
+/**
+ * Template View
+ *
+ * @author cmc <hello@cleberg.net>
+ */
+class Template
+{
+ public function __construct(string $canonical_url, string $page_description, string $page_title, string $content_col)
+ {
+ $this->canonical_url = $canonical_url;
+ $this->description = $page_description;
+ $this->title = $page_title;
+ $this->content = $content_col;
+ $this->current_year = date("Y");
+ }
+
+ public function echo_template()
+ {
+ // Get the template file
+ $template_file = 'templates/template.html';
+ $page = file_get_contents($template_file);
+
+ // Replace the template variables
+ $page = str_replace('{page_title}', $this->title, $page);
+ $page = str_replace('{page_description}', $this->description, $page);
+ $page = str_replace('{canonical_url}', $this->canonical_url, $page);
+ $page = str_replace('{content}', $this->content, $page);
+ $page = str_replace('{current_year}', $this->current_year, $page);
+
+ // Echo the filled-out template
+ echo $page;
+ }
+}
+
+// EOF