view mrjunejune/template_renderer.h @ 279:b3b547563ec7

Add Google connector service and agent wiki Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code. Co-authored-by: Copilot <[email protected]> Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 22:22:36 -0700
parents 04fee26ecce0
children
line wrap: on
line source

#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 */