Skip to content

Template processing #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
me21 opened this issue Nov 20, 2018 · 2 comments
Open

Template processing #25

me21 opened this issue Nov 20, 2018 · 2 comments
Labels

Comments

@me21
Copy link

me21 commented Nov 20, 2018

Please add the template engine.

It would be nice to be able to store the HTML file in SPIFFS and replace certain placeholders in it with their real values depending on some conditions. A callback function provided by user could return these values.

A similar feature exists in ESPAsyncWebServer: https://github.com/me-no-dev/ESPAsyncWebServer#template-processing

@fhessel
Copy link
Owner

fhessel commented Nov 20, 2018

Hi,
thanks for the feature request. That sounds like a useful addition to the library.

As far as I see by now, this will require #15 to be implemented first (ESPAsyncWebServer also does chunked transfer encoding in case the file contains templates).

Regarding storing the template files, I would prefer to keep SPIFFS etc. out of the server's code to minimize dependencies of the library and have a maximum of flexibility wrt. where you place your static files (SPIFFS, SD Card, Progmem, ...). By using the default handler you can add SPIFFS access relatively easy to your server and put a REST API on to. There are already examples out there on how to do this, look for instance at this blog post by Nathan McMinn.

I can put this onto my to do list, but I'll not be able to do the implementation by myself in the next few weeks.

@dethegeek
Copy link

Hi

I have the same need and build my own template implementation. It is currently limited to placeholder and include support, but this may be be a starting point for you and other people.

I just created a repo to share it here : https://github.com/dethegeek/esp-template . I apologize for the README file : I wrote it from scratch, may be incomplete or have some errors: i did not planned to share it as a standalone library. Questions / issues / PRs are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants