statik
statik copied to clipboard
Is it possible to use environment variables in context?
Is it possible to use environment variables (or some other type of configuration) in context variables?
The use case is the following - I have a static site with an external analytics service enabled. I'd like statik to include the analytics JS snippet only when building for deployment, not in development. If statik had the concept of development/production modes, this would be possible. Alternatively, some form of templating in the YAML config files would also help.
Is this currently possible somehow? If not, what should the ideal interface here look like? If the change is not too big, I could think about submitting a PR.
Statik is very cool btw. Thanks for writing it. I feel this is a static site generator that's done "right".
You could probably write a simple template tag that looked at os.environ['DEBUG'] or similar and returned either the JS snippet or null.
https://github.com/thanethomson/statik/wiki/Custom-template-tags-and-filters
Oh that's a good idea. I'll look into it.
So in general this works, but the flow is not that smooth. Some native support would still be nice. Maybe just a command line switch to specify which config file to pick instead of defaulting to config.yml in the current dir.
You can already specify a different config file from the command line just using the -p or --project switch. For example:
> statik -p my-custom-config.yml