Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Is it possible to use environment variables in context? #72

Open
siddhantgoel opened this issue Sep 23, 2018 · 4 comments
Open

Is it possible to use environment variables in context? #72

siddhantgoel opened this issue Sep 23, 2018 · 4 comments
Milestone

Comments

@siddhantgoel
Copy link

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".

@pztrick
Copy link
Contributor

pztrick commented Sep 26, 2018

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

@siddhantgoel
Copy link
Author

Oh that's a good idea. I'll look into it.

@siddhantgoel
Copy link
Author

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.

@thanethomson
Copy link
Owner

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

kx-chen added a commit to kx-chen/statik that referenced this issue Dec 6, 2018
Add environment variables to context so they
may be used in views.

Closes thanethomson#72
kx-chen added a commit to kx-chen/statik that referenced this issue Dec 6, 2018
Add environment variables to context so they
may be used in views.

Closes thanethomson#72
kx-chen added a commit to kx-chen/statik that referenced this issue Dec 6, 2018
Add environment variables to context so they
may be used in views.

Closes thanethomson#72
kx-chen added a commit to kx-chen/statik that referenced this issue Dec 6, 2018
Add environment variables to context so they
may be used in views.

Closes thanethomson#72
@thanethomson thanethomson added this to the v0.23.0 milestone Jan 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants