Replies: 4 comments 5 replies
-
Hello, I think more context is required to fully understand... You are using templates, right ? If yes, just know that there won't be any enhancements for that part in 3.x. 3.x line is only for bug fixes, and a new 4.x line will be started in a few months. And this is psosible that 4.x will drop templating support, except if someone is really motivated to implement it correctly., and with a standard templating engine (we need to discuss that with @me-no-dev). The current templating support is ok-ish, but now, there are several template engines available on ESP32 that are far more better than what ESP32AsyncWS has. It is also not the goal of a webserver to act as a template engine. So I strongly advise to look at integrating another engine (example: https://techtutorialsx.com/2021/09/13/esp32-inja-html-template-engine/), which will work for both 3.x and 4.x later. Do not rely on 3.x template engine if it cannot cover your needs. |
Beta Was this translation helpful? Give feedback.
-
I've been through this issue with my project and posted up previously on the old repo. me-no-dev#1249 It was also commonly reported elsewhere - https://github.com/me-no-dev/ESPAsyncWebServer/issues?q=is%3Aissue%20delimiter The % delimiter is a BAD choice as it is a valid / common character in CSS. So when the template engine comes across the % character in CSS, it breaks the template engine. The previous solution given to use %% instead to escape the character produces non-compliant CSS, which will fails CSS tests. This is obviously bad for the semantic web. (see my comments here) So ideally the character should be changed to one that does not clash with any of the common web based languages (css / html / xml / javascript / etc). Of course the change should also be backwards compatible with the current % character. There is a workaround... You can set a build flag in platformio.ini to change the placeholder...
However it is far more elegant and semantically correct to not use the % in the first place. /DM |
Beta Was this translation helpful? Give feedback.
-
I agree to change '%' by '~'. With Arduino IDE, I don't know where I can impact TEMPLATE_PLACEHOLDER='~' I try to add : #define TEMPLATE_PLACEHOLDER '~' unfortunatly, Arduino IDE using precompiled library doesn't take in consideration this with a modification in file WebResponseImpl.h, (I don't like, my code can't be share without a lot of explainations ... and survey at each new release) maybe someone can help me to avoid modification in file "WebResponseImpl.h" ? M |
Beta Was this translation helpful? Give feedback.
-
Thanks to DeeEmm and me-no-dev for the way, I summarize a solution working like a charm deletion of pre compiled libraries (only one time) // not necessary if you start with a new sketch : |
Beta Was this translation helpful? Give feedback.
-
Hello Mathieu,
I try to play with processor and placeholders but I face to some problems.
In fact, after (... a lot of tests ...), processor work fine on simple case, but when I have some % symbols in the code (not for delimitation of placeholder but for something else like modulo or real percentage is requested for printing) the function process try to catch and finally found nothing to replace and return an empty String, this situation scratch what is waiting in the browser.
I purpose to be more restrictive for placeholders name
centred in % like actually
name start and finish with underscore
name in only in uppercase, no space symbol
name including _ symbols need to be between 4 and 16 chars
so if i adapt to your example:
Placeholders are delimited with % symbols. Like this: %TEMPLATE_PLACEHOLDER%.
become
Placeholders names start with
%_
and finish by_%
, using only uppercase letters, nor space symbol and length between % char is 4 to 16 char . Like this:%_PLACEHOLDER_%
start with
%_
: Okfinish with
_%
: Okuppercase: Ok
no space: Ok
Length of PLACEHOLDER is 13 so more than 4 and less than 16: Ok
and for sure, I delegate the correspondant treatment inside library (I'm not able to do this)
Beta Was this translation helpful? Give feedback.
All reactions