Giter VIP home page Giter VIP logo

Comments (9)

rzeldent avatar rzeldent commented on September 24, 2024

from micro-moustache.

fletchjp avatar fletchjp commented on September 24, 2024

Rene

Thank you, I will do that. It will take a few days as I have a talk to give on Sunday. I will make some examples. I suggest I bump the version number. Shall I make it 1.1.0 as I have not changed your interface?

from micro-moustache.

rzeldent avatar rzeldent commented on September 24, 2024

from micro-moustache.

fletchjp avatar fletchjp commented on September 24, 2024

Rene

I have now made an example for my extra functions which are in a separate header file. I have changed the version number to 1.1.0 as the interface is not changed. I have added new material to the README file to describe how to use the new functions.

I do need to change the name of the folder holding the headers from 'include' to 'src' and I don't know whether that will break use on other hardware than a UNO.

I can make this into a pull request although I am not sure how best to do this.

In the meantime I am attaching a ZIP file with a copy of the library as I now have it configured. Please let me know whether this makes sense to you.

Best wishes

John
micro-moustache.zip

from micro-moustache.

rzeldent avatar rzeldent commented on September 24, 2024

from micro-moustache.

fletchjp avatar fletchjp commented on September 24, 2024

Rene

The difference is that I am running on an Arduino UNO where the messages are regarded as warnings because of the use of -fpermissive in the Arduino IDE setup. This applies on both the Arduino IDE 1.8.19 and 2.0.3 which use the same configuration file, for example

C:\Users\john\Documents\Arduino\examples\moustache_values\moustache_values.ino:49:40: warning: passing 'const String' as 'this' argument discards qualifiers [-fpermissive]
number_value[0].value = String(number);

I think you are working on a different system which provides different settings.

I have tried compiling the example for an Arduino DUE and that fails. The message is the same except that it is an error.

The reason it fails for the DUE is that -fpermissive is not defined. When I add it to the line compiler.cpp.flags in platform.txt then the errors become warnings and it compiles.

platform.txt is hidden away in the user's AppData\Local\Arduino15\packages on a Windows computer

I have tried in the past to find out just what -fpermissive does allow on different systems without success,

It may be that you can change the settings on your system, or just label my work for Arduino UNOs etc. I can now use a DUE as a test system to see if I can get around this.

I have taken the other approach and looked for a work around for the error and not found one (yet).

What do you think?

John

from micro-moustache.

fletchjp avatar fletchjp commented on September 24, 2024

I have had a look at ways to work around this problem without using -fpermissive. I have not found a solution.

I don't know what you think. Perhaps I should abandon this idea, except for the example for error messages.

John

from micro-moustache.

rzeldent avatar rzeldent commented on September 24, 2024

from micro-moustache.

rzeldent avatar rzeldent commented on September 24, 2024

Hi John,

I looked again at you extensions and basically what you want to do is not recreate the array but be able to update a particular value. This makes a lot of sense if you have a single/global instance.
So, maybe the const is too strict when using the moustache values. To overcome this I made the moustache_variable_t's value parameter not const, so it is posible to change it. I think this will make it easier to work with this library.

When using this version, the array is no longer allowed to be const. So below an example how to use it.
You can use your templates to change the values and then just call render.

Please give it a go and let me know what you think about this change see branch: feature/no_const.

Kind regards,

Rene

void setup()
{
    const char *taxes =
        "Hello {{name}}\n"
        "You have just won {{value}} dollars!\n"
        "{{#in_ca}}"
        "Well, {{taxed_value}} dollars, after taxes.\n"
        "{{/in_ca}}"
        "{{^in_ca}}"
        "And no taxes paid!\n"
        "{{/in_ca}}";

    moustache_variable_t substitutions[] = {
        {"name", "Chris"},
        {"value", String(10000)},
        {"taxed_value", String(10000 - (10000 * 0.4))},
        {"in_ca", String(true)}};

    auto result = moustache_render(taxes, substitutions);
    Serial.println(result);

    substitutions[3].value = String(false);
    result = moustache_render(taxes, substitutions);
    Serial.println(result);
}

from micro-moustache.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.