These are chat archives for canjs/canjs

Dec 2018
Viktor Busko
Dec 26 2018 14:04
Guys in can@3 is there any way to create var in template only. I have some property that purely view-related and I don't want to create viewModel property for it.
I use scope.vars for this purpose usually, but it used in "right hand side" so I put "somthing" to this scope.var, and I want to create kinda scope.vars.something:from="myHelper(param, param)". I assume Can@5 solves this with let helpers.
If you know any another way it might be interested as well. Basically I need to store helper execution results somewhere and then pass object with helper execution results somewhere else.
Frank Lemanschik
Dec 26 2018 14:09
sorry i don't understand
but if you would create some example code with a expected result
i probally know a hack around that
start a little codepen with some code for myHelper
let it simply return the expected html it don't needs to work then i can show you how
Viktor Busko
Dec 26 2018 15:16
its a bit hard to create example in Can@3. I'll try to rephrase. I would like to create variable in stache, assign it and use it :D Key point here that I don't have any data in viewModel.
Frank Lemanschik
Dec 26 2018 15:26
but why ?
i don't understand why you don't get the data from the viewModel
you should add functions inside of the viewModel that retrive data
the same logic that your helper does could be a function in the viewModel
Frank Lemanschik
Dec 26 2018 15:40
a way to get variables out of something into your template for can@3 is <can-import> @Lighttree
<can-dynamic-import from="MODULE_NAME" value:to="*MODULE_REF"/>
Dynamically import a module from within a can-stache template. Since there is no subtemplate to attach the Promise to as the current scope, you must export the Promise's resolved value to the template's refs scope using value:to.
so you code a module like
module.exports = { data: '' }+
and import that