This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-01
Channels
- # announcements (6)
- # atom-editor (4)
- # babashka (59)
- # beginners (51)
- # bristol-clojurians (6)
- # calva (5)
- # cider (22)
- # clara (6)
- # cljfx (28)
- # clojure (182)
- # clojure-australia (1)
- # clojure-berlin (1)
- # clojure-dev (21)
- # clojure-europe (12)
- # clojure-italy (8)
- # clojure-nl (7)
- # clojure-norway (13)
- # clojure-uk (20)
- # clojurescript (2)
- # code-reviews (24)
- # conjure (9)
- # cursive (9)
- # datomic (35)
- # defnpodcast (45)
- # fulcro (18)
- # graalvm (3)
- # graphql (1)
- # hugsql (1)
- # jobs (3)
- # jobs-discuss (2)
- # klipse (1)
- # leiningen (1)
- # malli (5)
- # membrane (4)
- # off-topic (7)
- # portal (2)
- # reitit (30)
- # remote-jobs (1)
- # rewrite-clj (5)
- # ring (2)
- # shadow-cljs (25)
- # test-check (2)
- # tools-deps (5)
- # vrac (26)
- # xtdb (17)
Inside the template’s grammar, there are 2 distinct modes:
In the html mode:
1. a literal vector is interpreted as the inclusion of a html node or a vrac component,
2. a if
is interpreted as a html-if
if its then and or else parameters are html nodes,
In the value mode:
1. a literal vector is interpreted as a value
2. a if
is interpreted as a value-if
.
The html-if
in going to be treated specially during the rendering process. With the html-for
node, it will be updated with a higher priority compared to any other nodes.
Thinking of which, the value-if
will have to be treated in a special way as well, as it won’t need both the data from its then and the else parameters.
The (val ...)
block is for explicitly stating that its content is to be understood in the value mode.
Maybe I should also keep
Or maybe they won’t care about the difference between the 2 ifs.html/if
and value/if
as reserved symbols for the users who don’t want to think about the modes, to make it simple.
Oh .. my mistake, it should count as the html-if
if any of the “then” or “else” is a html node.
;; then param is a value
;; else param is a html node
[:div (if foobar "then" [:div "else"])]
nil
counts at both a value and an html node. I am thinking that components should be allowed to return nil
, as well as (for ...)
blocks.— End of today’s brainstorming. Feedback is welcome, as always. My next step will be to aggregate all the things I wrote into an organized documentation file.
I am writing the documentation, and I realized that there is an important detail that I forgot to mention about data loading.
The templates let the system know what data is required for a full display of the template.
But what to do when the data is not loaded yet?
David Nolen suggested in one of his talks about OM Next that the component should not be displayed.
I have another solution more flexible:
;; Let's reuse the syntax from Clojure ! :-)
(let [cake (:cake global {:loaded? false
:name "The cake is a lie!"})]
[:div
{:class (if (:loaded? cake) :loaded :lie)}
(:name cake)])
Here is what I typed so far. The next section will be a description of the template’s grammar, mostly copy/paste from what I’ve written so far. As usual, feedback is super-mega-really welcome. Do not hesitate to ask questions, it helps me to find places where the documentation is lacking.
so you're thinking of adding an ability to provide the default state while component loads?
yes, knowing that the if
in the template will provide enough flexibility for the user to take advantage of it.
The default value will be used when the data is just not available, it does not necessary mean that it is loading.
Good night~
oh and might be an idea to do a version of this with Vrac https://github.com/ClojureTO/JS-Workshop