-
Notifications
You must be signed in to change notification settings - Fork 0
C API
Leonard Ramminger edited this page Aug 31, 2026
·
1 revision
The C FFI lives in prebyte_engine.h and builds as libprebyte_engine_c.
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);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);- Check return codes and null pointers from FFI calls.
- Read details with
prebyte_get_last_error(). - Free strings returned by the API with
prebyte_string_free().