These are chat archives for canjs/canjs

18th
Jul 2016
Gregg Roemhildt
@roemhildtg
Jul 18 2016 16:37
I'd like a professional opinion on something, Is there any problem with using the define plugin to include extra properties? For example, I'd like to add additional properties for a form component to use, like a label, fieldType, etc. This won't cause problems will it?
Kevin Phillips
@phillipskevin
Jul 18 2016 16:41
I don’t know if other people have opinions, but I do stuff like this and haven’t run into any issues:
    pickupPlaceholderText: {
      value: 'Choose Start Location'
    }
Sunil George
@georgesunil81
Jul 18 2016 16:42
Had a question on stache, how can I do OR/AND? For example {{#if hasDate OR hasTime}}, is there a good way to do it?
Kevin Phillips
@phillipskevin
Jul 18 2016 16:42
helpers
Sunil George
@georgesunil81
Jul 18 2016 16:43
Ah! so register a helper for OR and AND?
Kevin Phillips
@phillipskevin
Jul 18 2016 16:43
you could
Sunil George
@georgesunil81
Jul 18 2016 16:43
Read in all parms and return truthy or falsey as appropriate
Any other way?
Kevin Phillips
@phillipskevin
Jul 18 2016 16:44
specific helpers for what you’re ORing / ANDing
or viewmodel properties
Sunil George
@georgesunil81
Jul 18 2016 16:44
Oh! Can't I have a generic helper for ORing/ANDing that takes in variable number of parameters?
Kevin Phillips
@phillipskevin
Jul 18 2016 16:44
I haven’t run into situations where I’m doing enough OR / AND in a template to need a helper
sure, you could
Sunil George
@georgesunil81
Jul 18 2016 16:45
Hmmm, I see, I think I should avoid ORing/ANDing in the stache as much as possible then.
Jeremy Miller
@jjm340
Jul 18 2016 16:47
You could do your ORing/ANDing in the view model and just use the Boolean property on the view
Gregg Roemhildt
@roemhildtg
Jul 18 2016 16:47

@phillipskevin I actually meant doing something like this:

field: {
    value: 'default value',
    placeholder: 'Choose a value',
    fieldType: 'date-picker',
    //etc

It would simplify the map a lot, but could that cause issues since the define plugin doesn't have properties like placeholder...?

Kevin Phillips
@phillipskevin
Jul 18 2016 16:48
would you be able to access those properties?
Gregg Roemhildt
@roemhildtg
Jul 18 2016 16:49
Yep, I'm passing the map constructor to the form component
Kevin Phillips
@phillipskevin
Jul 18 2016 16:50
ok
Gregg Roemhildt
@roemhildtg
Jul 18 2016 16:50
so it would be something like map.prototype.define.field.placeholder
Kevin Phillips
@phillipskevin
Jul 18 2016 16:51
ok
I’m not sure if you’ll run into issues
Gregg Roemhildt
@roemhildtg
Jul 18 2016 16:52
The only issue I could see is if the define plugin ever gets additional properties besides value, get, set, etc.
They might collide