Embed templates
This commit is contained in:
13
routes.c
13
routes.c
@ -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) {
|
||||
|
Reference in New Issue
Block a user