Fork me on GitHub
#vrac
<
2020-09-01
>
yogthos00:09:50

ah makes sense

yogthos00:09:17

a bit of syntax sugar helps

Vincent Cantin00:09:10

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 .

Vincent Cantin00:09:01

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.

Vincent Cantin00:09:31

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.

Vincent Cantin00:09:35

The (val ...) block is for explicitly stating that its content is to be understood in the value mode.

Vincent Cantin00:09:31

Maybe I should also keep html/if and value/if as reserved symbols for the users who don’t want to think about the modes, to make it simple. Or maybe they won’t care about the difference between the 2 ifs.

Vincent Cantin00:09:09

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.

Vincent Cantin00:09:51

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

Vincent Cantin19:09:00

I am writing the documentation, and I realized that there is an important detail that I forgot to mention about data loading.

Vincent Cantin19:09:39

The templates let the system know what data is required for a full display of the template.

Vincent Cantin19:09:00

But what to do when the data is not loaded yet?

Vincent Cantin19:09:27

David Nolen suggested in one of his talks about OM Next that the component should not be displayed.

Vincent Cantin19:09:39

I have another solution more flexible:

Vincent Cantin19:09:12

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

Vincent Cantin20:09:57

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.

yogthos20:09:33

so you're thinking of adding an ability to provide the default state while component loads?

Vincent Cantin20:09:14

yes, knowing that the if in the template will provide enough flexibility for the user to take advantage of it.

Vincent Cantin20:09:27

The default value will be used when the data is just not available, it does not necessary mean that it is loading.

yogthos20:09:46

I like that, a very clean way to get the default behavior

yogthos20:09:07

oh and might be an idea to do a version of this with Vrac https://github.com/ClojureTO/JS-Workshop

👍 3
yogthos20:09:32

a kind of a step by step introducing different features from something really basic

yogthos20:09:37

and g'night 🙂