These are chat archives for ractivejs/ractive

9th
Jan 2018
Paul Maly
@PaulMaly_twitter
Jan 09 2018 09:34
Also for consistensy with other blocks, seems we need to support short syntax too, like: {{#promise}} ... {{/}}
if promise is actually promise
Juan C. Andreu
@andreujuanc
Jan 09 2018 10:53
I like where this is going.
Also like it more with curly than element-like notation.
Paul Maly
@PaulMaly_twitter
Jan 09 2018 10:54
:+1:
Juan C. Andreu
@andreujuanc
Jan 09 2018 10:57
Maybe else should be for anything that is not a promise? That would simplify templates and reduce error
Also Paul and I have very similar profile pictures xD
Paul Maly
@PaulMaly_twitter
Jan 09 2018 11:29

Maybe else should be for anything that is not a promise? That would simplify templates and reduce error

I believe probably no, because 1) consistency with other blocks; 2) you don't need to worry about from where actual value come from - local storage cache or ajax request:

{{#await fetchPosts() }}
Loading posts....
{{then posts}}
<ul>
    {{#posts}}
         <li>{{ .title }}</li>
    {{/posts}}
</ul>
{{else}}
No posts...
{{/await}}
function fetchPosts() {
    return localStorage.getItem('posts') || fetch('/posts').then(r => r.json());
}
Juan C. Andreu
@andreujuanc
Jan 09 2018 11:34
Makes sense
Paul Maly
@PaulMaly_twitter
Jan 09 2018 11:37
I also believe that developer using such cool tool like Ractive doesn't need to worry about sync/async values at all. Ractive already so powerful and this common case (promises/async values/etc) need to be in Ractive's competence too.
Juan C. Andreu
@andreujuanc
Jan 09 2018 11:41
Yep. For now I'm using promise alt. Can't wait to have this natively!
Have guys talk about what version this will be included with?
Paul Maly
@PaulMaly_twitter
Jan 09 2018 12:23
Exactly, when it'll be in core, I'll be able to trash a ton of my own patches, which I use in absolutely all my projects.
Chris Reeves
@evs-chris
Jan 09 2018 19:18
I don't think plain block syntax is really doable at this point
that's built into sections, which don't really async well, and has quite a bit of weirdness around it already
this would go out with a 0.10 along with some computed adjustments and hopefully template-level shuffle support so that computeds and expressions can be told to shuffle at the {{#each}} level
all three are breaking
Paul Maly
@PaulMaly_twitter
Jan 09 2018 20:06
You know better, but then I think we should remove this opportunity for other blocks for the good consistency.
From docs
Sections render a block of markup depending on the value referenced.
If the reference is an array, it renders the block of markup for each item in the array.
we can paraphrase
If the reference is a promise, it renders the block of markup as await block.
Chris Reeves
@evs-chris
Jan 09 2018 20:24
my only issue with that is that plain blocks only require one chunk of template to be useful, whereas an await requires two
I wouldn't be opposed to removing {{elseif}} and {{else}} support from plain mustaches, but I'd imagine others would be
I'd actually rather not have plain mustache blocks at all
Paul Maly
@PaulMaly_twitter
Jan 09 2018 20:30
I think consistency and predictability is the best way. So, if we can't make {{#await /}} block to support plain syntax, I also join my vote to skip this syntax from other blocks too. I believe it's just a syntax sugar
Maybe it even makes Ractive little bit simpler inside. )))