tests-always-included / mo

Mustache templates in pure bash
Other
563 stars 67 forks source link

Change variable testing behaviour #10

Closed athieriot closed 8 years ago

athieriot commented 8 years ago

Hi there !

It might not be an acceptable behaviour regarding Mustache specs but here is my use case: I intend to use mo in a Docker Image in order to build specific configuration files based on some Env variables (at runtime then).

I am really attracted by mo because it's so small, fits well in an Alpine based image and got the small sets of features I need (Conditionals mainly).

However, I had like to support the fact that people might want part of the configuration to be deactivated when using such syntax: SYSTEM_ENABLED=false

So here a Pull Request if you are interested but I would totally get that supporting the value "false" make much more sense in the context of this tool. If there is an alternative way to support my use case within Mustache (Using a command line argument for example), I had be glad to make the change.

Thanks

fidian commented 8 years ago

I'm closing this pull request because I am biased towards not enabling this behavior by default. Since all environment variables are technically strings, one should set it to an empty string or not define a value in the first place.

However, there is obvious merits to allowing false to be considered empty, so I've added a flag --false and an environment variable MO_FALSE_IS_EMPTY and both may trigger this behavior. If that does not work out for your use case, please let me know.

athieriot commented 8 years ago

Thank you @fidian !

Your update looks amazing :) And rest assured it will work perfectly in the use case of a Docker image as I can enable it quite easily.

That was very useful indeed.