Skip to content

C++ API

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

C++ API

Headers ship with the engine install or source tree under include/.

High-level session API

Best for one-shot or file-based rendering with variables and CLI-like behavior.

#include "PrebyteEngine.h"

int main() {
    prebyte::Prebyte prebyte;
    prebyte.set_variable("name", "Ada");
    prebyte.add_argument("first-extra");
    std::string output = prebyte.process("Hello {{ name }}\n");
}

Low-level compile/render API

Best for compile-once, render-many workflows.

#include "Engine.h"

prebyte::Engine engine;
prebyte::CompiledTemplate tpl = engine.compile("Hello {{ name }}\n");

prebyte::RenderContext ctx;
ctx.set("name", "Ada");

std::string output = engine.render(tpl, ctx);

Notes

  1. render() wraps render_to()
  2. RenderContext supports scalar and structured Value
  3. compile_file(path) uses path as source and logical path
  4. load_compiled_file(path) loads top-level .pbc

CMake consumers

find_package(prebyte-engine CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE prebyte::engine_static)

C FFI

For other languages, use the C API in C API (prebyte_engine.h, libprebyte_engine_c).

Clone this wiki locally