so here’s a goofy question, how do you reference the css that garden
generates, like say in a hiccup template?
how to use/consume seems to be omitted from the docs/wiki unless i’m missing it. thnx
perhaps a better question is… > what is a common preferred pattern for how/where to define your css with garden and consume/inject it?
The lazy answer is to do what traditionally has always been done with CSS which is just knowing what IDs and classes are available and referencing those when writing your markup.
I usually create a style.cljc
namespace in my project and create a route that will serve the rendered CSS rather than spitting it out to a file which makes code reloading a bit of a pain.
Then I’ll have a reference to that route path in my HTML structure in the <head>
.
For a different (arguably more modern) approach, check out this article: https://blog.estimate-work.com/a-new-world-writing-css-in-clojurescript-and-life-after-sass-bdf5bc80a24f
yeah i’ve read that article, and it’s good, just handy to see actual example implementations
Here’s my use of Garden: https://github.com/niamu/hawkthorne-return/blob/master/src/hawkthorne/router.cljc#L41
https://github.com/niamu/hawkthorne-return/blob/master/src/hawkthorne/style.cljc
ah cool, this is helpful thanks.
you’re creating a stylesheet
then you’re defining a render function that calls garden/css on that stylesheet
and i see the call to style/render in your response :body
Right. So that way any changes to the style.cljc
namespace during development always gives me the latest CSS in the route rather than having to spit out a new file of the rendered CSS.