These are chat archives for canjs/canjs

4th
Dec 2018
Viktor Busko
@Lighttree
Dec 04 2018 07:02
Hi guys, can someone explain how canjs publish model works?
For example in can-stache there is master branch for upstream version and 3.x branch for CanJS@3 as far as I got.
But I didn't see tags for 3.x versions in GitHub (and NPM requires them as I know), so lets say we need to make change for CanJS@3 (and change version) when CanJS@5 already exists, how this handled ?
I'm asking because we need to support existent components for CanJS@3 and CanJS@5 for some time, and currently there is only master with tags for CanJS@3, so was thinking about same approach.
Frank Lemanschik
@frank-dspeed
Dec 04 2018 14:26
@Lighttree as far as i know you need to simply checkout a v3 branch
and release a patch version
thats it
it will publish that to npm and canjs main has no pinned versions so it will always install latest patched
thats the suggested flow at present
here you can see it
the mixed release v2 releases and v3 and v5 pre
Kevin Phillips
@phillipskevin
Dec 04 2018 15:10
3.x-legacy is the branch name
there are docs here about how to publish can@3 and its sub-packages: http://v3.canjs.com/doc/guides/contribute.html
I'm not sure why can-stache doesn't have v3 tags in github
Frank Lemanschik
@frank-dspeed
Dec 04 2018 15:15
i think because can-stache 4
is also used in v3
@phillipskevin as far as i remember
ok i was wrong its "can-stache": "3.15.0",
"can-stache-bindings": "3.11.12",
"can-stache-converters": "3.3.1",
and there are tags and releases for can-stache by the way
Kevin Phillips
@phillipskevin
Dec 04 2018 15:38
yeah, they just don't show up in github @Lighttree. probably just because they're older
$ git tag | grep v3.
v3.0.0
...
v3.14.7
v3.14.8
v3.14.9
v3.15.0
v3.15.1
...
v3.7.1
v3.7.2
v3.7.3
v3.8.0
v3.9.0
Viktor Busko
@Lighttree
Dec 04 2018 21:01
Thanks for clarification.
Paul Tichonczuk
@tracer99
Dec 04 2018 21:05
we're going through this right now. Had to manually set steal-stache to 3
Kevin Phillips
@phillipskevin
Dec 04 2018 21:31
what do you mean @tracer99 ?
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:42

Hey guys. Not sure if I've encountered a bug. I'm using the let context, but if I have several of these in a row, it seems to put chrome in an endless cpu loop:

{{let field = ...}}
...
{{let field = ...}}
.... etc

The point is, there's multiple calls to let field = something else and it causes lots of issues.

For this case, I think with is the best choice, but it appears that with is going to be removed eventually?
Matthew Phillips
@matthewp
Dec 04 2018 21:48
@roemhildtg are you trying to reassign the field every time?
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:48
Corret
Matthew Phillips
@matthewp
Dec 04 2018 21:48
are you reassigning like inside of an #if or something?
what's the purpose to reassign I guess is my question
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:50
Well, I have this stache renderer on several different field type objects. The renderer references a variable field, so I need the variable field to be available in the stache template. I'm rendering a list of these fields like so:
        {{let field = fieldsMap.fieldName}}
        {{>field.editComponent}}
        {{let field = fieldsMap.otherFieldName}}
        {{>field.editComponent}}
Matthew Phillips
@matthewp
Dec 04 2018 21:50
can you file an issue in can-stache? We definitely haven' thought of this use case
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:51
editComponent is like this:
stache(`<${tag} properties:from="field"
        object:from="dirtyObject"
        value:bind="dirtyObject[field.name]" 
        error:bind="validationErrors[field.name]"
        on:fieldchange="checkField(scope.arguments)"></${tag}>`);
I really am open to doing this a better way though. I can open an issue
Kevin Phillips
@phillipskevin
Dec 04 2018 21:54
each of those fields will be the same variable
since the LetContext is at the template level
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:54
It won't reassign them, right?
Kevin Phillips
@phillipskevin
Dec 04 2018 21:54
what won't?
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:55
the second time I call let field = ..something else it won't reassign field?
Matthew Phillips
@matthewp
Dec 04 2018 21:55
right
we hadn't thought about that yet
can you name them something different each time?
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:56
gotcha
Justin Meyer
@justinbmeyer
Dec 04 2018 21:56
so let in stache are a bit different than let in JS
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:56
I can't rename them unless I changed how the editComponent template works
Justin Meyer
@justinbmeyer
Dec 04 2018 21:56
b/c they are "live"
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:56
Right now, editComponent is a template that references the variable field in the template
Justin Meyer
@justinbmeyer
Dec 04 2018 21:56
you can call editComponent with a local field
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:57
As in... using with?
Justin Meyer
@justinbmeyer
Dec 04 2018 21:57
{{partial(field=something)}}
that will pass a local field
Gregg Roemhildt
@roemhildtg
Dec 04 2018 21:57
hmm
I'll give tha t a try
Justin Meyer
@justinbmeyer
Dec 04 2018 21:59
@matthewp / @roemhildtg what do you think something like the following should do:
{{let field="abc"}}
<p>{{field}}</p>
{{let field="def"}}
<div>{{field}}</div>
Matthew Phillips
@matthewp
Dec 04 2018 21:59
im a bit conflicted, in JavaScript this would throw
i don't know if {{field="def"}} is possible for reassigning
Gregg Roemhildt
@roemhildtg
Dec 04 2018 22:00
What about this?
{{let field="abc"}}
<p>{{field}}</p>
{{/let}}<!-- field is no longer referenced -->
{{let field="def"}}
<div>{{field}}</div>
{{/let}}
Justin Meyer
@justinbmeyer
Dec 04 2018 22:00
You would need # in {{#let field="abc"}}
Gregg Roemhildt
@roemhildtg
Dec 04 2018 22:00
Does that currently work?
Justin Meyer
@justinbmeyer
Dec 04 2018 22:01
I'm not sure {{#let}} is currently supported ... let (haha!) me check
Gregg Roemhildt
@roemhildtg
Dec 04 2018 22:01
haha
So would that still create the new scope that with did?
Because I like how let works, where I don't need to use ../
Justin Meyer
@justinbmeyer
Dec 04 2018 22:01
a different type of scope
yeah ... it would create a variable scope on top of the current context
where with would add a new context
it currently doesn't work
letHelper would need to detect if it was called with # (by checking if it was passed an options). If it was, it would call options.fn() with a new LetContext
and return the result of options.fn
Can you create an issue? It's fairly straightforward (if you know a lot about stache :P )
Gregg Roemhildt
@roemhildtg
Dec 04 2018 22:05
I'll put together an issue
Gregg Roemhildt
@roemhildtg
Dec 04 2018 22:12
OK, in the meanwhile - {{fieldsMap.number.editComponent(field=fieldsMap.number)}} does render the field partial I want. BUT it doesn't appear to be binding correctly. The only scope that gets passed is the field
Do I still need to pass the dirtyObject, object, and other props that my partial needs?
I kind of need to do something like this maybe... editComponent(this=mixin(this, field=fieldsMap.number))
Gregg Roemhildt
@roemhildtg
Dec 04 2018 22:23
Is there any way to make stache use alet scope in this scenario?
Justin Meyer
@justinbmeyer
Dec 04 2018 23:04
in what scenario?
so you can create your own scope if you want
and pass that
you could make a helper that makes a scope just how you'd like
Gregg Roemhildt
@roemhildtg
Dec 04 2018 23:05
True. That's a good approach
Justin Meyer
@justinbmeyer
Dec 04 2018 23:05
editComponent(makeScope( fieldsMap))
makeScope(field){
  return new Scope( whatYouWant_this_toBe ).addLetContext( {variable1: VALUE} )
}
Gregg Roemhildt
@roemhildtg
Dec 04 2018 23:10
:thumbsup:
I gotta run. Have a good night!