Fork me on GitHub
#hoplon
<
2017-09-04
>
thedavidmeister03:09:41

i don't think :css should be getting stripped

thedavidmeister03:09:48

can you provide the actual code where it is missing?

thedavidmeister03:09:54

i can run it through a test to confirm

fiddlerwoaroof03:09:07

Ok, let me try to recreate the issue...

fiddlerwoaroof03:09:22

Hmm, it's not happening now, let me see if there's anything obvious about the state of the code when I was having problems

fiddlerwoaroof03:09:37

(defelem feed-item [{item :item path :path :as attrs} _]
  (let [[get-item title item-path link content] (get-item-cells item)
        toggled (cell false)
        leftover-attrs (dissoc attrs :item :path)]
    (article leftover-attrs
             (header (h3 (a :href link title)) " "
                     (button :click #(dosync (get-item @base-url @path @item-path)
                                             (swap! toggled not))
                             ">>"))
             (div :class (cell= {"content" true "displayed" toggled "hidden" (not toggled)})
                  :html content))))

(defelem feed-view [{feed :feed} _]
  (let [[url title path feed-cell items item-count] (get-feed-entry-cells base-url feed)
        child-width (cell= (column-width item-count))]
    (section
     (if-tpl (cell= (> item-count 0))
       (div 
        (header (h2 title) (p url))
        (loop-tpl :bindings [item items]
          (feed-item :path path :item item :css {:width child-width})))))))

fiddlerwoaroof03:09:08

I'm still reading through it to see if I can spot a mistake, but I think this was the code that was acting strangely

fiddlerwoaroof03:09:51

Hmm, I think the :css {:width child-width} part might be missing a cell=

fiddlerwoaroof03:09:11

It looks like that was the issue

thedavidmeister05:09:13

i've done the same thing a few times

thedavidmeister05:09:21

easy to forget that you need the cell for css

fiddlerwoaroof05:09:22

It would be nice if hoplon could treat cells passed as values of the map the way it treats cells as an attribute value.

thedavidmeister07:09:21

@fiddlerwoaroof i'm on the fence about that. i feel the ratio of convenience to complexity isn't a clear win

thedavidmeister07:09:16

it wouldn't just be for that one css attribute, you'd have to teach it how to traverse arbitrarily nested data structures for any attribute and what to do when it finds a cell at any level

thedavidmeister07:09:22

and you'd have to decide if/what to do with event handler functions in nested structures

thedavidmeister07:09:25

the thing is that atm you can always build up a map in the way that you want in a let or something and then pass the final composite value through to :css