aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2025-07-10 22:12:22 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2025-07-10 22:12:22 +0530
commit2a65c3971513c44fa0c124c4e1e6e89c823c8501 (patch)
treea28f8669607bb4293f02c5846c00f6571104d7b4 /src
parent9a2b779bb2f5f771604c22ddd0ac6d7932b900ff (diff)
template: template_ingest() should work with _RAW
Diffstat (limited to 'src')
-rw-r--r--src/template.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/template.c b/src/template.c
index 311ab3b..fae66dc 100644
--- a/src/template.c
+++ b/src/template.c
@@ -1,9 +1,11 @@
+#include <string.h>
#define _GNU_SOURCE
#include <filehandler.h>
#include <lexer.h>
#include <stdlib.h>
#include <template.h>
+#include <util.h>
#include "../config.h"
@@ -22,3 +24,27 @@ template_create(void)
return template;
}
+
+char *
+template_ingest(template_t *template, char *body)
+{
+ (void) body;
+ char *output = malloc(1);
+ strcpy(output, "");
+
+ for (size_t i = 0; i < template->components->size; i++) {
+ directive_t *match = list_get(template->components, i);
+
+ switch (match->type) {
+ case _RAW:
+ xstrcat(output, match->operands);
+ break;
+
+ /* TODO: Handle this gracefully */
+ default:
+ break;
+ }
+ }
+
+ return output;
+}