mirror of
https://github.com/alexhopeoconnor/DFTE.git
synced 2026-10-17 11:51:30 +10:00
Add DYNAMIC_DATA placeholder for raw streamed template content
Support registering dynamic String/progmem data without re-parsing as nested templates, used by WiFiManager for composed portal stylesheets.
This commit is contained in:
@@ -90,6 +90,7 @@ public:
|
||||
* @return true if registered successfully
|
||||
*/
|
||||
bool registerRamData(const char* name, PlaceholderDataGetter getter);
|
||||
bool registerDynamicData(const char* name, const DynamicDataDescriptor* descriptor);
|
||||
bool registerDynamicTemplate(const char* name, const DynamicTemplateDescriptor* descriptor);
|
||||
bool registerConditional(const char* name, const ConditionalDescriptor* descriptor);
|
||||
bool registerIterator(const char* name, const IteratorDescriptor* descriptor);
|
||||
@@ -124,6 +125,7 @@ public:
|
||||
// Static helper functions for length calculation
|
||||
static size_t getProgmemLength(const void* data);
|
||||
static size_t getRamLength(const void* data);
|
||||
static size_t getDynamicDataLength(const DynamicDataDescriptor* descriptor, const char* data);
|
||||
static size_t getDynamicTemplateLength(const DynamicTemplateDescriptor* descriptor, const char* templateData);
|
||||
|
||||
private:
|
||||
@@ -138,6 +140,8 @@ private:
|
||||
uint8_t* dest, size_t maxLen);
|
||||
static size_t copyRamData(PlaceholderDataGetter getter, size_t offset,
|
||||
uint8_t* dest, size_t maxLen);
|
||||
static size_t copyDynamicData(const DynamicDataDescriptor* descriptor, size_t offset,
|
||||
uint8_t* dest, size_t maxLen);
|
||||
};
|
||||
|
||||
#endif // DEVICEFRAMEWORK_PLACEHOLDER_REGISTRY_H
|
||||
|
||||
@@ -31,6 +31,7 @@ enum class PlaceholderType {
|
||||
PROGMEM_DATA, // Large PROGMEM data (CSS, JS, base64 images)
|
||||
PROGMEM_TEMPLATE, // Nested template in PROGMEM
|
||||
RAM_DATA, // Dynamic RAM data via getter functions
|
||||
DYNAMIC_DATA, // Dynamic RAM data via getter + userData, rendered as raw bytes
|
||||
DYNAMIC_TEMPLATE,
|
||||
CONDITIONAL,
|
||||
ITERATOR
|
||||
@@ -64,6 +65,12 @@ typedef void* (*IteratorOpenHandler)(void* userData);
|
||||
typedef IteratorStepResult (*IteratorNextHandler)(void* handle, struct IteratorItemView& view);
|
||||
typedef void (*IteratorCloseHandler)(void* handle);
|
||||
|
||||
struct DynamicDataDescriptor {
|
||||
DynamicTemplateGetter getter;
|
||||
DynamicTemplateLengthGetter getLength;
|
||||
void* userData;
|
||||
};
|
||||
|
||||
struct DynamicTemplateDescriptor {
|
||||
DynamicTemplateGetter getter;
|
||||
DynamicTemplateLengthGetter getLength;
|
||||
|
||||
Reference in New Issue
Block a user