Embed templates

This commit is contained in:
kamkow1
2025-06-09 22:10:49 +02:00
parent ac48e49ecc
commit a8c5d7817d
8 changed files with 84 additions and 4 deletions

View File

@ -3,6 +3,7 @@
#include "routes.h"
#include "gpp.h"
#include "tmpls.h"
void route_page_not_found(struct mg_connection *conn, struct mg_http_message *msg)
{
@ -13,7 +14,11 @@ void route_page_not_found(struct mg_connection *conn, struct mg_http_message *ms
String_Builder out = {0};
defer { sb_free(&out); }
bool ok = gpp_run("./tmpls/page-missing.t", &env, &out);
char path[PATH_MAX] = {0};
tmpl_get_path_by_key(TMPL_PAGE_MISSING, path, sizeof(path));
bool ok = gpp_run(path, &env, &out);
sb_finish(&out);
if (!ok) {
@ -42,7 +47,11 @@ void route_home(struct mg_connection *conn, struct mg_http_message *msg)
String_Builder out = {0};
defer { sb_free(&out); }
bool ok = gpp_run("./tmpls/index.t", &env, &out);
char path[PATH_MAX] = {0};
tmpl_get_path_by_key(TMPL_HOME, path, sizeof(path));
bool ok = gpp_run(path, &env, &out);
sb_finish(&out);
if (!ok) {