diff mrjunejune/template_renderer.h @ 264:04fee26ecce0

add authenticated JRPG conversation platform Add reusable auth/session storage, owned conversation recovery, guest quotas, admin workflows, URL-routed conversation UI, mobile frame support, and parallel browser acceptance. Co-authored-by: Copilot <[email protected]>
author MrJuneJune <me@mrjunejune.com>
date Fri, 07 Aug 2026 07:34:12 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mrjunejune/template_renderer.h	Fri Aug 07 07:34:12 2026 -0700
@@ -0,0 +1,45 @@
+#ifndef MJJ_TEMPLATE_RENDERER_H
+#define MJJ_TEMPLATE_RENDERER_H
+
+/*
+ * template_renderer.h — site-owned HTML template renderer for mrjunejune.
+ *
+ * Expands {{/path}} include tokens by loading files relative to the
+ * configured document root.  Provides overflow-safe output into a
+ * caller-supplied buffer allocated from a Dowa_Arena.
+ */
+
+#include "dowa/dowa.h"
+
+/*
+ * Set the document root used for all subsequent renders.
+ * Must be called once before the first render (not thread-safe vs
+ * concurrent renders; fine to call before the server accepts requests).
+ * Defaults to "mrjunejune/src" if never called.
+ */
+void Mjj_Template_Renderer_Init(const char *src_root);
+
+/*
+ * Render the NUL-terminated template string `tmpl` into `out[0..cap-1]`,
+ * replacing every {{/path}} token with the contents of the file at
+ * g_src_root + path.  `out` is always NUL-terminated on return.
+ *
+ * Returns TRUE  — all text fit; out contains the fully expanded page.
+ * Returns FALSE — output exceeded cap, or tmpl is NULL.
+ *   (out may contain a partial result; treat FALSE as a 500.)
+ *
+ * Missing includes are skipped silently; they never cause FALSE.
+ * arena is used only for temporary include-name copies (not freed here).
+ */
+boolean Mjj_Template_Render(
+    char *out, size_t cap, const char *tmpl, Dowa_Arena *arena);
+
+/*
+ * Load the file at g_src_root + path, then render its includes.
+ * Returns FALSE if the file cannot be opened or if cap is exceeded.
+ * Equivalent to loading the file and calling Mjj_Template_Render.
+ */
+boolean Mjj_Template_Render_File(
+    char *out, size_t cap, const char *path, Dowa_Arena *arena);
+
+#endif /* MJJ_TEMPLATE_RENDERER_H */