canjs / can-view-import

Import dependencies in CanJS views
https://canjs.com/doc/can-view-import.html
MIT License
3 stars 2 forks source link

Allow static `<can-import>` to synchronously access the module #111

Open justinbmeyer opened 6 years ago

justinbmeyer commented 6 years ago
<can-import from="./my-module" module.default:to="scope.vars.myModule"/>
{{ console.log(scope.vars.myModule) }} <!-- SHOULD LOG SOMETHING -->

https://github.com/canjs/can-view-import/blob/master/can-view-import.js#L38 GitHub canjs/can-view-import can-view-import - Import dependencies in CanJS views

matthew [3:03 PM] https://github.com/canjs/steal-stache/blob/master/steal-stache.js#L11 GitHub canjs/steal-stache steal-stache - A plugin that allows you to import stache templates with stealjs.

That would need to change to dynamically take in the dependencies values

then pass those into stache so that can-view-import can pluck them out

Not too hard i don't think

justinbmeyer commented 5 years ago

I've just added this to 6.0 as the one other breaking change I think we should make.

While I'd like to do #610, I think that feature can be added in later.

I do think we should make this work with let variables now too ... so the following works:

<can-import from="./my-module" module.default:to="anyVariable"/>

But if scope.vars.X is used, that should still work (but work synchronously)

<can-import from="./my-module" module.default:to="scope.vars.myModule"/>