lifeart/els-component-extraction-addon

Pass in any attributes/arguments that existed in the original template

Closed this issue · 6 comments

from:

template.hbs

<div>{{this.msg}}</div>

to:

template.hbs

<HelloWorld @msg={{this.msg}} />

components/hello-world.hbs

<div>{{@msg}}</div>

refs: https://github.com/ember-template-lint/ember-template-recast

sample implementation - https://astexplorer.net/#/gist/43cfbcb18d878f83403fe5d9142ab302/fb00a7a231bb8c3335df7423dc6286621e04b365


cases to figure out how to handle:

{{@foo}} {{this.foo}}

-> adds scoped prefix for this. cases with overlapped namespaces.

<MyComponent @foo={{@foo}} @scopedFoo={{this.foo}} />
-----------------------------------------
{{@foo}} {{@scopedFoo}}

{{this.foo.bar}} {{this.foo.bar.baz}}

-> instead of @bar={{this.foo.bar}} @baz={{this.foo.baz}} - @foo={{this.foo}}

<MyComponent @foo={{this.foo}} />
-----------------------------------------
{{@foo.bar}} {{@foo.bar.baz}}

one more example - https://astexplorer.net/#/gist/f035b50dd7222759fc70e128557fd668/729932462b61b99b710676532e3bb5cd05be1faa

cases to figure out how to handle:

{{#let this.boo as |foo|}}
-----
{{@foo}} {{this.foo}} {{foo}}
-----
{{/let}}

we need to use registry to check, if helper exists or not, if not - use localFoo, else - skip path.
like hasHelperWith name, or check for . inside {data: false, this:false} paths.

You are on 🔥

I will try to find the time this week to try to start tackling this :)