hoplon

The :hoplon: ClojureScript Web Framework - http://hoplon.io/
rlander 2020-02-19T04:56:18.044800Z

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> .

rlander 2020-02-19T04:56:27.045100Z

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

rlander 2020-02-19T05:51:28.046600Z

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.

2020-02-19T07:02:44.046900Z

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

2020-02-19T07:02:55.047200Z

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

rlander 2020-02-19T07:06:38.048500Z

@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.

rlander 2020-02-19T07:07:32.049200Z

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

2020-02-19T07:08:14.050Z

please do, thanks

rlander 2020-02-19T07:08:51.050400Z

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

2020-02-19T07:09:14.050900Z

great! i have yet to use shadow myself

rlander 2020-02-19T07:09:35.051300Z

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

rlander 2020-02-19T07:11:23.052400Z

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

1👍
rlander 2020-02-19T20:44:37.054Z

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

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

rlander 2020-02-19T20:44:50.054300Z

But this doesn't:

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

rlander 2020-02-19T20:46:53.056Z

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))

rlander 2020-02-19T20:47:12.056400Z

Isn't for-tpl supposed to auto deref?

rlander 2020-02-19T20:47:25.056700Z

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

rlander 2020-02-19T20:50:20.057800Z

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

2020-02-19T23:43:00.059200Z

@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

2020-02-19T23:44:40.060300Z

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

2020-02-19T23:44:55.060700Z

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

2020-02-19T23:46:27.061600Z

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

2020-02-19T23:46:39.061800Z

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

2020-02-19T23:47:28.062400Z

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=

2020-02-19T23:47:47.062800Z

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