String indexProcessor(const String& key) {
Serial.println(String("KEY IS ") + key);
if (key == "TITLE") return "Hello World!";
else if (key == "BODY") return "It works!";
return "oops";
}
void handleRoot() {
if (ESPTemplateProcessor(server).send(String("/index.html"), indexProcessor)) {
Serial.println("SUCCESS");
} else {
Serial.println("FAIL");
server.send(200, "text/plain", "page not found.");
}
}
It's a header-only library right now on github: https://github.com/winder/ESPTemplateProcessor