noprompt / garden

Generate CSS with Clojure
1.35k stars 88 forks source link

make at-media and similar helpers evaluated later #86

Open niquola opened 9 years ago

niquola commented 9 years ago

Now when you use at-media in the middle of garden data structure - it starts eager evaluation, so we are loosing data nature of result. It would be cool to make it lazy:

[:body {}
   [at-media {} & rules] ;; (not (at-media)
   [:h3 {:line-height [px 5]}]] ;; (not (px 5))

and evaluate lately in (css)

noprompt commented 9 years ago

@niquola I'm in agreement. Laziness would be cool. However, I think there is a broader problem (which I've eluded to previously) in that Garden itself doesn't have a data format that's granular enough to represent this sort of thing without the record format it currently uses. Personally, I would rather have an underlying data format that is closer to a parse tree. This would enable the library to be far more flexible.

[:css/rule
 [:css/selector "body"]
 [:css/at-media
  [:css/block
   [:css/rule
    [:css/selector "h3"]
    [:css/block
     [:css/declaration
      [:css/property "line-height"]
      [:css/value
       [:css/comma-separated-list
        [:css/unit
         [:css/number 5]
         [:css/measurement "px"]]]]]]]]]]
niquola commented 9 years ago

:+1: