Fork me on GitHub
#hoplon
<
2020-02-19
>
rlander04:02:18

Hi! So, I'm trying to add a class that depends on a predicate (`(kid :class (cell= {:active state}))`) but, no matter what I do, the markup ends up <a class="{:active true}" href="/">Home</a> .

rlander04:02:27

Not sure what I'm doing wrong here...

rlander05:02:28

Answering my own question: after digging through the code, it seems that I have to either require hoplon.jquery or hoplon.goog so that the multimethod can be loaded.

alandipert07:02:44

@rlander glad you found it, you're not the first to run into this

alandipert07:02:55

i added a note to https://github.com/hoplon/hoplon/wiki/HTML-Attributes-and-JS-Events#default-on-methods, feel free to edit anywhere on the wiki you would have expected to find it

rlander07:02:38

@alandipert thanks for the link! I totally missed that page. I guess it wouldn't hurt to add a link here: https://github.com/hoplon/hoplon/wiki/Cookbook, under Attribute Inheritance.

rlander07:02:32

I'll update that page with the link if that's all right.

alandipert07:02:14

please do, thanks

rlander07:02:51

btw, I'm experimenting with Hoplon + shadow-cljs and I'm really enjoying the experience.

alandipert07:02:14

great! i have yet to use shadow myself

rlander07:02:35

I might create a starter-template if anyone else is interested

rlander07:02:23

@alandipert I'll leave the link here when I'm done for you to poke around then.

👍 4
rlander20:02:37

Assuming I have an element called article-preview, why does this work:

(for-tpl [article global-feed]
      (div (cell= (article-preview article)))))

rlander20:02:50

But this doesn't:

(for-tpl [article global-feed]
      (cell= (article-preview article)))))

rlander20:02:53

Also, why do I have to deref within article-preview when I try this:

(for-tpl [article global-feed]
      (article-preview article)))))
    ....
    (defn article-preview [article]
      (h2 (:title @article))

rlander20:02:12

Isn't for-tpl supposed to auto deref?

rlander20:02:25

I guess I'm very confused about the nuances of cell deref.

rlander20:02:20

I want to help with the documentation, but I guess I need a firmer grasp of how deref'ing cells work.

alandipert23:02:00

@rlander these are excellent observations, in the first case you mention i would say for-tpl stands for "for template" and the body of the for-tpl must evaluate to a non-cell, concrete piece of markup

alandipert23:02:40

internally for-tpl is instantiating as many instances of the template it needs to have one for each element of global-feed at any time

alandipert23:02:55

so as global-feed grows and shrinks it recycles existing ones if it can

alandipert23:02:27

i think it might be possible for you to conditionalize the "top-level" of the template by using if-tpl

alandipert23:02:39

but i haven't used hoplon myself in awhile and i forget

alandipert23:02:28

for your 2nd question, for-tpl doesn't auto-deref i don't think. the binding name is a cell. so it will only auto-deref if you refer to it in a cell=

alandipert23:02:47

i.e. article as received by article-preview is a Cell