These are chat archives for canjs/canjs

20th
Nov 2017
Nico R.
@nriesco
Nov 20 2017 01:54
Hi, I need to use the old @index helper (https://v2.canjs.com/docs/can.stache.helpers.index.html) in a canjs v3 project.
but changing my current {{#each todos }} to {{#each(todos)}} fails
I use can-stache 3.6.0
Julian
@pYr0x
Nov 20 2017 08:34
scope.index ?
Frank Lemanschik
@frank-dspeed
Nov 20 2017 08:35
was genau ist die frage
ja ein scope hat index
example
['elem1','eleme']
index 1 index 2
the position in the scope if you use a each
each === for loop
the function gets (i, val)
1 element
2 eleme
you remember kevins example each keys, key = value
he setted index is key val = value
Julian
@pYr0x
Nov 20 2017 09:43
no, i answered @nriesco question
Frank Lemanschik
@frank-dspeed
Nov 20 2017 09:44
Oh hahahahha logical :)
sometimes i am wondering about how stupid i am i should always read the lines on top also
Nico R.
@nriesco
Nov 20 2017 14:28
@pYr0x thanks but it seems that if I don’t use the {{#each(todos)}} syntax it just won’t work
and that syntax won’t work for me
Frank Lemanschik
@frank-dspeed
Nov 20 2017 14:42
@nriesco why dont u use
{{#todos}} {{/todos}}
inside that you can easy use every todo fild like {{completed}}
i never use each :)
Julian
@pYr0x
Nov 20 2017 14:51
each has some improvments
Frank Lemanschik
@frank-dspeed
Nov 20 2017 14:51
what?
Frank Lemanschik
@frank-dspeed
Nov 20 2017 14:51
i can't imagin some :)
you mean that you can re name the bindings?
the values
yes sure
but for normal listing of data its not needed most times
Gregg Roemhildt
@roemhildtg
Nov 20 2017 14:52
Each has performance benefits in some cases
Kevin Phillips
@phillipskevin
Nov 20 2017 15:08
@nriesco did you file an issue for your problem?
and yes, {{#each}} with Lists will do diffing when the list changes (values inserted, removed, etc)
{{#list}} will re-render the entire list
Nico R.
@nriesco
Nov 20 2017 16:00
@phillipskevin is it really an issue or does that syntax only work for a newer versions of can (can-stache?) I’m using 3.6.0
Kevin Phillips
@phillipskevin
Nov 20 2017 16:12
I meant... @index not working
that should work
Nico R.
@nriesco
Nov 20 2017 16:27
@phillipskevin submitted: canjs/can-stache#379
Kevin Phillips
@phillipskevin
Nov 20 2017 16:34
does %index work?
Nico R.
@nriesco
Nov 20 2017 16:35
let me check
no
it does not work
{{%index}}
nor {{@index}}
they both print 0
for any number of lines
I added a comment
Kevin Phillips
@phillipskevin
Nov 20 2017 16:42
ok, thanks
would it be hard to update to 3.13.5 to see if the issue still exists?
Nico R.
@nriesco
Nov 20 2017 17:05
@phillipskevin same thing
Kevin Phillips
@phillipskevin
Nov 20 2017 17:05
ok, thanks
Nico R.
@nriesco
Nov 20 2017 17:06
wait
I think the new syntax now works
so, the new syntax works now but this code will only print 0’s:
{{#if mainModelPromise.isResolved}}
  {{#each(mainModelPromise.value, todo=value num=index)}}
    ONE LINE1: {{num}}<br>
  {{else}}
    no results
  {{/each}}
{{/if}}
maybe I need to do {{#each(mainModelPromise, todo=value num=index)}} ?
Nico R.
@nriesco
Nov 20 2017 17:11
no, that change breaks the app
Kevin Phillips
@phillipskevin
Nov 20 2017 17:26
all of these things use the same code path
num=index, scope.index, %index
so if one doesn't work, I doubt the others will
it is probably an issue with promises
we'll look into it
Nico R.
@nriesco
Nov 20 2017 17:28
thanks!