These are chat archives for canjs/canjs

8th
Nov 2017
Julian
@pYr0x
Nov 08 2017 00:31
does can-autorender not have reference scope?
<div type='text/stache' can-autorender>
<x-entnahmestelle-tab-content entnahmestelle-id="" vm:detailPromise:to="scope.vars.detailPromise" vm:entnahmestelle-id:to="scope.vars.bar"></x-entnahmestelle-tab-content>
</div>
Julian
@pYr0x
Nov 08 2017 00:45
scope.vars.bar is not defined inside the div (with can-autorender)
Julian
@pYr0x
Nov 08 2017 01:03
the whole stache binding syntax between components is not working with can-autorender
@phillipskevin any idea if this is a bug or not supported
{{bar}} is not shown as 1
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 08 2017 09:32
@pYr0x happy for you :)
Julian
@pYr0x
Nov 08 2017 09:32
puuhh... that was a terrible night
;)
Kevin Phillips
@phillipskevin
Nov 08 2017 15:29
I think that should work, but it's a little hard to tell
can you try it in jsbin @pYr0x ?
Julian
@pYr0x
Nov 08 2017 15:30
what do you mean it is hard to tell?
is there a boilerplate jsbin with canjs?
Kevin Phillips
@phillipskevin
Nov 08 2017 15:31
yeah, there's a link at the top of gitter
it's hard to tell why it isn't working just from that gist
just from looking at it
Julian
@pYr0x
Nov 08 2017 15:35
can-autorender is not inside of can-all
i will create a github repo
Kevin Phillips
@phillipskevin
Nov 08 2017 15:37
oh, it's only with autorender, right
thanks
hmm, I wonder why it's not in can.all
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 08 2017 15:39
@phillipskevin @pYr0x maybe because it needs a loader eg: stealjs
Kevin Phillips
@phillipskevin
Nov 08 2017 15:40
it shouldn't
well... I guess it wouldn't work in jsbin
with the global build
Julian
@pYr0x
Nov 08 2017 15:45
i will publish a github repo
with a simple example
Julian
@pYr0x
Nov 08 2017 19:27
@phillipskevin here is a example
all three examples are not working
Julian
@pYr0x
Nov 08 2017 19:45
first two are not working
those with can-autorender
Frank Lemanschik
@frank-dspeed
Nov 08 2017 20:03
wait i will fix it for you
Frank Lemanschik
@frank-dspeed
Nov 08 2017 20:10
@pYr0x the fail is that your inital template
is not a component
var template = stache('<x-main><x-first vm:foo:from="scope.vars.foo"></x-first><br><x-second vm:bar:to="scope.vars.foo"></x-second><br>Reference: {{scope.vars.foo}}</x-main>');

document.querySelector("#append").appendChild(template({}));
don't produces a scope
@pYr0x how should i solve that we can make that a can-component or we can make it a can-element
or i can manual bind scope to that template
what do you prefer for educational ?
i prefer can-element
but you choose
Julian
@pYr0x
Nov 08 2017 22:05
@frank-dspeed i had a typo
i will update the repo soon
@phillipskevin i have found the bug
kamelCase does not work on can-autorender
Frank Lemanschik
@frank-dspeed
Nov 08 2017 22:05
did that work without setting scope?
Julian
@pYr0x
Nov 08 2017 22:06
vm:fooBar:from does not converted to vm:foo:u:bar:from
@phillipskevin @frank-dspeed github repo is now online
Frank Lemanschik
@frank-dspeed
Nov 08 2017 22:08
ok the hackertron starts
:D
but what do you think about making that a component or element?
so it has a scope :)
i think that should be a good idea in general
what do you mean by "make that a component"
the problem is not the component
the problem is can-autorender
Frank Lemanschik
@frank-dspeed
Nov 08 2017 22:09

import stache from "can-stache";

var template = stache('<x-main>\n <x-first vm:fooBar:from="scope.vars.foo"></x-first>\n <br>\n <x-second vm:barFoo:to="scope.vars.foo"></x-second>\n <br>\n Reference: {{scope.vars.foo}}\n</x-main>');

document.querySelector("#append").appendChild(template({}));

this part in main.js
your importing components then you render a stach fragment
Julian
@pYr0x
Nov 08 2017 22:10
yes
Frank Lemanschik
@frank-dspeed
Nov 08 2017 22:10
and that fragment don't has a can-view-scope
Julian
@pYr0x
Nov 08 2017 22:10
it has
why not?
Frank Lemanschik
@frank-dspeed
Nov 08 2017 22:10
because stache don't assigns scope
you can see it well in the can-element.js
Julian
@pYr0x
Nov 08 2017 22:11
template({})
Frank Lemanschik
@frank-dspeed
Nov 08 2017 22:11
yes template rendering don't assigns scope
Julian
@pYr0x
Nov 08 2017 22:11
{} is an empty scope
Frank Lemanschik
@frank-dspeed
Nov 08 2017 22:11
hmmm
i don't think so
as when we reigster that with domData we would pass new can-view-scope
Julian
@pYr0x
Nov 08 2017 22:11
the object you pass into, gets the scope of the temlate
Frank Lemanschik
@frank-dspeed
Nov 08 2017 22:11
to get a empty viewscope
i only can tell you that from my findings
i did elements with the same tech like you befor i knowed about that
and nothing worked like can-import and that
Julian
@pYr0x
Nov 08 2017 22:13
hm
Frank Lemanschik
@frank-dspeed
Nov 08 2017 22:13
for example your stache only renders the components
because you importet them in the same js
sykpe?
Frank Lemanschik
@frank-dspeed
Nov 08 2017 22:13
ya add me
Julian
@pYr0x
Nov 08 2017 22:15
hab ich
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 08 2017 22:25
@pYr0x did you see the warning WARN: can-stache/src/expression.js: Unable to find key or helper "scope.vars.foo". ?
Julian
@pYr0x
Nov 08 2017 22:25
yes
vm:fooBar:from does not converted to vm:foo:u:bar:from
thats the main problem
Kevin Phillips
@phillipskevin
Nov 08 2017 22:42
ok, so can-view-parser isn't running on the autorender script
sounds like a bug
sorry I haven't had a chance to look yet
can you open an issue @pYr0x and link to your repo?
Julian
@pYr0x
Nov 08 2017 23:04
ok
Kevin Phillips
@phillipskevin
Nov 08 2017 23:08
I'll open one @pYr0x
already started writing it
Julian
@pYr0x
Nov 08 2017 23:08
ok thanks :)
Kevin Phillips
@phillipskevin
Nov 08 2017 23:09
you're right - if you encode the attributes then it works fine
Kevin Phillips
@phillipskevin
Nov 08 2017 23:15
opened canjs/can-view-autorender#70 @pYr0x
Julian
@pYr0x
Nov 08 2017 23:16
thanks
Kevin Phillips
@phillipskevin
Nov 08 2017 23:16
horrible workaround in case this is blocking you: you can encode them yourself
Julian
@pYr0x
Nov 08 2017 23:27
i do now