mirror of
https://github.com/alexhopeoconnor/DFTE.git
synced 2026-10-03 22:21:59 +10:00
v1.2.1
DeviceFramework Template Engine (DFTE)
DFTE streams HTML and text from ESP8266 and ESP32 firmware without constructing a complete response in RAM. Store layouts in PROGMEM, resolve changing values through getters, and render fixed-size chunks directly to serial or an asynchronous HTTP response.
Render a first template
#include <TemplateEngine.h>
static const char PAGE[] PROGMEM = "<h1>%TITLE%</h1>";
PlaceholderRegistry registry;
TemplateContext context;
void setup() {
Serial.begin(115200);
registry.registerProgmemData(PSTR("%TITLE%"), PSTR("Hello DFTE"));
registry.registerProgmemTemplate(PSTR("%PAGE%"), PAGE);
context.setRegistry(®istry);
TemplateRenderer::initializeContext(context, PSTR("%PAGE%"));
}
void loop() {
uint8_t chunk[128];
if (!TemplateRenderer::isComplete(context) && !TemplateRenderer::hasError(context)) {
Serial.write(chunk, TemplateRenderer::renderNextChunk(context, chunk, sizeof(chunk)));
}
}
Build Hello Placeholder to see the rendered result over serial.
Choose an example
| Example | What you will build |
|---|---|
| Hello Placeholder | the smallest registry, context, and serial-rendering flow |
| Nested Layouts | reusable partials, conditions, and iterator sections |
| Streaming Async | a streamed ESPAsyncWebServer response over a SoftAP |
| Async Dashboard Demo | a live dashboard with iterator rows and captive-portal access |
Why DFTE
- Bounded response memory: render fixed-size chunks instead of allocating one large
String. - Flash-resident layouts: keep templates, CSS, and shared fragments in PROGMEM.
- Live values: resolve dynamic information only as the active response needs it.
- Async-safe rendering: each HTTP request owns its rendering context while sharing the prepared registry.
Install
lib_deps =
DeviceFrameworkTemplateEngine=https://github.com/alexhopeoconnor/DFTE.git#v1.2.1
PlatformIO checks out the Git ref after #; GitHub Release assets are unrelated. DFTE supports ESP8266 and ESP32 Arduino projects.
See getting started, the documentation index, examples, changelog, and licence.
Languages
C++
93.8%
C
4.3%
Shell
1.9%