Files
esp32cam-rtsp/lib/template_render/template_render.h
Rene Zeldenthuis cbf0dbffbc Fixed template typo
2022-09-10 01:29:42 +02:00

19 lines
379 B
C++

#pragma once
#include <Arduino.h>
typedef struct
{
const char *key;
const String value;
} template_substitution_t;
template <typename T, size_t n>
inline String template_render(const char *format, T (&values)[n])
{
auto s = String(format);
for (size_t i = 0; i < n; i++)
s.replace("{{" + String(values[i].key) + "}}", values[i].value);
return s;
}