Skip to content
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

Allow to override default template placeholder value with #define during compilation #366

Merged
merged 1 commit into from
Jul 24, 2018

Conversation

me21
Copy link
Contributor

@me21 me21 commented May 19, 2018

There was a number of complaints from library users who needed to use the symbol of template placeholder in their data as-is. It seems that doubling the symbol (%% to get a single % in the output) doesn't work. While that should be fixed, the code of template engine is convoluted, so the proper fix might take some time.

This is a simple workaround: if the user #defines TEMPLATE_PLACEHOLDER during build, its value will be used. If not, default value of % is used.

…ing compilation.

Signed-off-by: Alexandr Zarubkin <me21@yandex.ru>
@me21
Copy link
Contributor Author

me21 commented May 19, 2018

Er, the build error seems to have nothing to do with the changes.

@JamesNewton
Copy link

JamesNewton commented Jun 28, 2018

I would really love to see this pulled. @me-no-dev any chance you can make this change for us? It's a big help for other people who I ask to install this library in order to compile the projects I'm sending them.

@JamesNewton
Copy link

I have a concern, confusion about this. Does the Arduino IDE re-compile a library if a define related to the library changes in the main .INO? I don't think it will. Triggering a re-compile of a library is a royal pain, as far as I can tell. Even just changing the library src doesn't update the code until you trackdown the arduinobuild folder and delete the .o file, right? So this isn't going to work. The only way to fix this is to make the template character a variable, which then needs a user interface to set it to other than the default. I hope I'm wrong here.

@me21
Copy link
Contributor Author

me21 commented Jul 3, 2018

The #define should change not in the main .INO file, it should be passed as -D flag to the compiler during build. Or #defined directly in the library header file, but that's less suitable, I think. Both ways should trigger library recompiling.
On the other hand, of course, it can be made a variable, it will enable using templates with different placeholder characters.

@me-no-dev me-no-dev merged commit fc66fae into me-no-dev:master Jul 24, 2018
@me-no-dev
Copy link
Owner

Sorry :( ESP32 things have been keeping me quite busy.

@me21 me21 deleted the configure-placeholder branch July 25, 2018 21:06
@zuqualla
Copy link

zuqualla commented Jun 5, 2019

still a relevant thread! i solve it for now by putting my css width:100% in a separate file (without templates).

Putting the #define TEMPLATE_PLACEHOLDER in my main code doesn't work. Due to the scope of #define?

Changing it in the library itself is annoying when it gets updated.

@me21
Copy link
Contributor Author

me21 commented Jun 5, 2019

You need to define that symbol as a build flag passed to the compiler. That's not easy to do in Arduino, but trivial in more sophisticated build systems (Platformio, etc.)

@zuqualla
Copy link

zuqualla commented Jun 5, 2019

@me21, thanks for your reply!
it's not a nice solution though, cause if we'd do this for every library we use it would become messy.

Why not pass it like server.templatePlaceholder = "$"?
I wish i had the skills to change it here on github, but still learning. So have to wait till one of you change it :)

ps: Platformio seems to have sold there soul to Microsoft, so for me that's a nogo. (i know about Atom, but it's looks they are moving away from it)

@me21
Copy link
Contributor Author

me21 commented Jun 5, 2019

I'm afraid this repo is not actively maintained, at least currently :-(. So doing it yourself may be quicker.
Besides, this pull request is already merged. I think you should create new issue.

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

Successfully merging this pull request may close these issues.

4 participants