Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By wwinder
#61319 I wasn't able to find an unintrusive library to help with HTML templates and the ESP8266WebServer class, so I created one. The basic usage is similar to the template callback system in esphttpd, it also loads the template out of the SPIFFS. Here's a small example of what it looks like to use:

Code: Select allString 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