mirror of
https://github.com/alexhopeoconnor/DFTE.git
synced 2026-10-03 22:21:59 +10:00
50 lines
1.6 KiB
C
50 lines
1.6 KiB
C
#ifndef TEMPLATE_ENGINE_H
|
|
#define TEMPLATE_ENGINE_H
|
|
|
|
/**
|
|
* DeviceFramework Template Engine
|
|
* Main public API header - include this in your projects
|
|
*
|
|
* Memory-efficient streaming template renderer for ESP8266/ESP32
|
|
* Supports chunked rendering with PROGMEM templates and nested template support
|
|
*
|
|
* Usage:
|
|
* 1. Create a PlaceholderRegistry and register your placeholders
|
|
* 2. Create a TemplateContext
|
|
* 3. Set the registry on the context
|
|
* 4. Initialize with your template
|
|
* 5. Call renderNextChunk() repeatedly until complete
|
|
*
|
|
* Example:
|
|
* DeviceFrameworkPlaceholderRegistry registry;
|
|
* registry.registerProgmemData("%CSS%", my_css);
|
|
*
|
|
* DeviceFrameworkTemplateContext ctx;
|
|
* ctx.setRegistry(®istry);
|
|
* DeviceFrameworkTemplateRenderer::initializeContext(ctx, my_template);
|
|
*
|
|
* uint8_t buffer[512];
|
|
* while (!DeviceFrameworkTemplateRenderer::isComplete(ctx) &&
|
|
* !DeviceFrameworkTemplateRenderer::hasError(ctx)) {
|
|
* size_t written = DeviceFrameworkTemplateRenderer::renderNextChunk(ctx, buffer, sizeof(buffer));
|
|
* server->sendContent((const char*)buffer, written);
|
|
* }
|
|
*/
|
|
|
|
// Type definitions first
|
|
#include "DeviceFrameworkTemplateTypes.h"
|
|
|
|
// Core components
|
|
#include "DeviceFrameworkTemplateRenderer.h"
|
|
#include "DeviceFrameworkTemplateContext.h"
|
|
#include "DeviceFrameworkPlaceholderRegistry.h"
|
|
#include "DeviceFrameworkTemplateEngineDebug.h"
|
|
|
|
// Type aliases for convenience
|
|
using TemplateRenderer = DeviceFrameworkTemplateRenderer;
|
|
using TemplateContext = DeviceFrameworkTemplateContext;
|
|
using PlaceholderRegistry = DeviceFrameworkPlaceholderRegistry;
|
|
|
|
#endif // TEMPLATE_ENGINE_H
|
|
|