mbutterick / pollen-users

please use https://forums.matthewbutterick.com/c/typesetting/ instead
https://forums.matthewbutterick.com/c/typesetting/
52 stars 0 forks source link

better handling of environment variables? #6

Closed mbutterick closed 5 years ago

mbutterick commented 5 years ago

I’m working on a project where I’d like to use mutiple environment variables (not just POLLEN). You don’t need Pollen’s permission to do this, but ordinarily the cache only tracks the value of the POLLEN variable itself, so if you use others, the cache will not be invalidated correctly (assuming that the other environment variables affect the output).

I’m thinking of adding pollen/setup value — let’s call it envvar-watchlist — that would allow a project to specify the environment variables that matter. (Simply looking at all the environment variables is not a good policy.)

Thoughts? Objections? Improvements?

sorawee commented 5 years ago

I'd love this feature! If possible, I'd also love a feature that enables Racket file that calls render to communicate Racket values to Pollen files that are being rendered -- though I understand if that's not possible. Dealing with namespaces is hard.

mbutterick commented 5 years ago

I'd also love a feature that enables Racket file that calls render to communicate Racket values to Pollen files that are being rendered

Can you give me an example?

mbutterick commented 5 years ago

BTW I’ve now pushed an update with envvar-watchlist:

(define envvar-watchlist '("PUB"))
sorawee commented 5 years ago

Can you give me an example?

Someone asks in the Slack channel a few months ago about this. Pretty much, s/he wants to render twice, each with different parameter. Trying to mutate variables doesn't work because they live in different namespace. The final solution we came up with is using environment variables, but being able to use Racket values are obviously better and less restrictive than using environment variables.

(The Slack post was gone due to Slack limitation)

mbutterick commented 5 years ago

Someone asks in the Slack channel a few months ago about this … The Slack post was gone

Well if they come back and post a question here, I will look into it. Otherwise I can only speculate …