ring

Saikyun 2020-03-30T05:11:31.006200Z

how would one set some code from the http-server that is "injected" into my cljs-code? in my case I want to set an url to a server depending on which server my cljs-code is running from. like so:

server hosting cljs          rest api server
localhost                    localhost:1234
<http://dev.internal.se|dev.internal.se>              <http://dev.internal.se/api|dev.internal.se/api>
<http://prod.com|prod.com>                     <http://api.prod.com|api.prod.com>
right now I use ring and just serve static files. was thinking that maybe one could modify something in the files when ring sends the static files

seancorfield 2020-03-30T05:15:30.007Z

@saikyun Maybe use Selmer to have mostly static templates with a few variables substituted?

👌 1
Saikyun 2020-03-30T05:18:28.007600Z

@seancorfield thanks for the tip! I'll check it out 🙂 definitely seems to do what I want to do 🙂

seancorfield 2020-03-30T05:28:32.008100Z

We use Selmer very heavily at work to generate HTML pages from templates and data.

Saikyun 2020-03-30T05:36:23.009Z

cool 🙂 did I understand Selmer correctly, that it doesn't re-generate html pages if the data hasn't changed?

Saikyun 2020-03-30T05:36:26.009200Z

sounds very useful

seancorfield 2020-03-30T05:52:45.010300Z

It precompiles the templates (if I recall correctly), but it still generates the HTML each time -- but it's fast. We serve millions of pages a day with it.

seancorfield 2020-03-30T05:53:26.011Z

(we use it to generate all the emails we send, as well as all the HTML pages we generate from several apps)

Saikyun 2020-03-30T05:53:39.011300Z

aha, cool. we're nowhere that amount, so that's reassuring 🙂

Saikyun 2020-03-30T05:55:18.012300Z

decided to solve it using :closure-defines in shadow-cljs for now, but I'll probably need more than "environment variables" in the future. then I'll keep Selmer in mind 🙂