These are chat archives for canjs/canjs

21st
Mar 2016
Julian
@pYr0x
Mar 21 2016 00:26
@justinbmeyer a electron gulp task can look like this: https://github.com/pYr0x/testapp/blob/master/gulpfile.js . this app works with electron on windows. how can we make this gulp task more doneJS-like? if you want we can talk about. let me know
Christopher Oliphant
@RALifeCoach
Mar 21 2016 17:01
Does CanJS support {{#if [helper] arg1 arg2}}
Guido Smeets
@gsmeets
Mar 21 2016 17:04
It supports {{#helper arg1 arg2}}
Christopher Oliphant
@RALifeCoach
Mar 21 2016 17:04
thanks
Guido Smeets
@gsmeets
Mar 21 2016 17:04
Where helper implements the if by calling options.fn and options.inverse
For the if/else blocks respectively
Check out mustache_helpers.is for examples
.js *
Kevin Phillips
@phillipskevin
Mar 21 2016 17:09
you can also do {{#if helper(arg1, arg2)}}
depending on what your helper does, it might simplify it to use a call expression
Guido Smeets
@gsmeets
Mar 21 2016 17:21
Helper is a viewmodel method in that example, isn't it?
I haven't used the 2.3 syntax yet
Kevin Phillips
@phillipskevin
Mar 21 2016 17:22
it doesn’t need to be
it will look at the viewmodel and then the helpers
Christopher Oliphant
@RALifeCoach
Mar 21 2016 17:26
in stache how do I check the condition xxx > yyy?
when does it make sense to add a function to the viewModel versus as a helper?
Kevin Phillips
@phillipskevin
Mar 21 2016 17:45
it’s much easier to unit test functions or properties on the viewModel
Guido Smeets
@gsmeets
Mar 21 2016 17:59
I only use helpers if I have no other option
Kevin Phillips
@phillipskevin
Mar 21 2016 18:03
that’s basically my approach also
or for global things like language translation or different formatters
Christopher Oliphant
@RALifeCoach
Mar 21 2016 18:04
thanks, what about the other question? xxx > yyy in stache
Kevin Phillips
@phillipskevin
Mar 21 2016 18:04
you’ll have to use a function
Christopher Oliphant
@RALifeCoach
Mar 21 2016 18:05
would it make more sense to use mustache or ejs for complex templates? are those available as options?
Kevin Phillips
@phillipskevin
Mar 21 2016 18:06
I would use can.stache
it has a lot of performance benefits and other features compared to mustache
ejs is depracated
and can’t be used with components
Christopher Oliphant
@RALifeCoach
Mar 21 2016 18:14
any plans on expanding stache to include #gt, #lt, etc.?
Kevin Phillips
@phillipskevin
Mar 21 2016 18:22
not that I know of
definitely feel free to open an issue to request it
Christopher Oliphant
@RALifeCoach
Mar 21 2016 19:05
Thanks. In fact if you point me to the code, I could create a PR.
This message was deleted
This message was deleted
Julian
@pYr0x
Mar 21 2016 19:12
so what is the problem?
Christopher Oliphant
@RALifeCoach
Mar 21 2016 19:12
I was just in the process of deleting the message
I have figured it out
Thanks
Christopher Oliphant
@RALifeCoach
Mar 21 2016 19:43
I am building Map’s with defines
I am liking what is provided here
How do I specify an array of Types?
Kevin Phillips
@phillipskevin
Mar 21 2016 19:44
like a single property that can have multiple types?
Christopher Oliphant
@RALifeCoach
Mar 21 2016 19:45
no, something like xxx: [ Person, Person]
Kevin Phillips
@phillipskevin
Mar 21 2016 19:47
so you want a property on a Map that is a list where each entry is a Person?
Christopher Oliphant
@RALifeCoach
Mar 21 2016 19:47
yes - your question probably explained the answer - can.List.extend({ define: person: {Type:Person}})
Kevin Phillips
@phillipskevin
Mar 21 2016 19:48
something like that, yeah
Christopher Oliphant
@RALifeCoach
Mar 21 2016 19:48
thanks
Kevin Phillips
@phillipskevin
Mar 21 2016 19:48
the define plugin isn’t 100% supported on can.List
Guido Smeets
@gsmeets
Mar 21 2016 19:48
Type: Person.List
Christopher Oliphant
@RALifeCoach
Mar 21 2016 19:53
@gsmeets that isn’t working either
when I use {{person[0].status}} I am getting [object Object]
that was the same result as what I typed earlier
Kevin Phillips
@phillipskevin
Mar 21 2016 19:54
does
{{#each person}}
  {{status}}
{{/each}}
show the same thing?
Christopher Oliphant
@RALifeCoach
Mar 21 2016 19:55
that works with Type: Person.List
that’s good enough to keep me going, but how would I reference person[0]?
Kevin Phillips
@phillipskevin
Mar 21 2016 19:58
you can either do something like add a first property to your list or a firstPerson property to your map
actually… does {{person.0}} work?
Christopher Oliphant
@RALifeCoach
Mar 21 2016 19:58
it does
thanks
Kevin Phillips
@phillipskevin
Mar 21 2016 19:59
sure
Christopher Oliphant
@RALifeCoach
Mar 21 2016 19:59
is there a type for Function?
Christopher Oliphant
@RALifeCoach
Mar 21 2016 20:16
other questions: I have an array of strings - how do I represent that in a Map? How do I show one or more values in stache?
For the Map I have tried String.List, that seems to be okay
Thomas Sieverding
@Bajix
Mar 21 2016 20:17
Make it a can.List
Christopher Oliphant
@RALifeCoach
Mar 21 2016 20:18
Once it is a can.List - how do I show the items?
Thomas Sieverding
@Bajix
Mar 21 2016 20:19
{{#each myList}}
  <p>{{.}}</p>
{{/each}}
Christopher Oliphant
@RALifeCoach
Mar 21 2016 20:19
thanks
Thomas Sieverding
@Bajix
Mar 21 2016 20:19
. means current context, which would be the string if it’s an array of strings
Christopher Oliphant
@RALifeCoach
Mar 21 2016 20:20
Thank-you. BTW String.List worked in my Map.define
Thomas Sieverding
@Bajix
Mar 21 2016 20:22
Do not use String.List
Messing w/ native prototypes is taboo
Christopher Oliphant
@RALifeCoach
Mar 21 2016 20:22
okay, what should I use in my Map.define
Thomas Sieverding
@Bajix
Mar 21 2016 20:23
{
  define: {
    myList: {
      value: Array
    }
  }
}
I always use value: Array/Object, and combine that w/ Type unless it’s a can.List/can.Map, which is implicit
Kevin Phillips
@phillipskevin
Mar 21 2016 20:24
@RALifeCoach just so you know, you don’t need to always set the Type
Christopher Oliphant
@RALifeCoach
Mar 21 2016 20:24
how would define know whether it is an array of numbers or strings?
Kevin Phillips
@phillipskevin
Mar 21 2016 20:25
it doesn’t need to know
Thomas Sieverding
@Bajix
Mar 21 2016 20:25
define’s really just used for fine-grain control of properties on maps
Christopher Oliphant
@RALifeCoach
Mar 21 2016 20:25
While I agree I don’t always need to set the type, good practice suggests that the more information I provide, the better
Guido Smeets
@gsmeets
Mar 21 2016 20:47
I generally try to avoid string lists tbh
I think about half the places where I used it I had to add some property besides the string at some point in the lifetime of that functionality
and then I had to convert it to a Map.List anyways
Christopher Oliphant
@RALifeCoach
Mar 21 2016 20:48
Unfortuneately, this is legacy code and I don’t have the option to make those kinds of changes
Guido Smeets
@gsmeets
Mar 21 2016 20:50
always go with what works ;)
I'm in the process in converting a whole slew of legacy code as well
one spec at a time ;)