Skip to content
Leonard Ramminger edited this page Aug 31, 2026 · 1 revision

C API

The C FFI lives in prebyte_engine.h and builds as libprebyte_engine_c.

Session API

High-level API similar to PrebyteEngine.h:

#include "prebyte_engine.h"

prebyte_session_t* session = prebyte_session_create();
prebyte_session_set_variable(session, "name", "Ada");
char* output = prebyte_session_render(session, "Hello {{ name }}\n");
prebyte_string_free(output);
prebyte_session_destroy(session);

Engine API

Compile-once, render-many:

prebyte_engine_t* engine = prebyte_engine_create();
prebyte_compiled_template_t* tpl =
    prebyte_engine_compile(engine, "Hello {{ name }}\n", NULL);

prebyte_render_context_t* ctx = prebyte_render_context_create();
prebyte_render_context_set(ctx, "name", "Ada");

char* output = prebyte_engine_render(engine, tpl, ctx);
prebyte_string_free(output);

prebyte_render_context_destroy(ctx);
prebyte_compiled_template_destroy(tpl);
prebyte_engine_destroy(engine);

Error handling

  1. Check return codes and null pointers from FFI calls.
  2. Read details with prebyte_get_last_error().
  3. Free strings returned by the API with prebyte_string_free().

Clone this wiki locally