-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Named templates within a class-based component don't have this
#249
Comments
Multiple templates within a class is not supported that way. The component assigned to a variable is a template-only component. :/ The relationship here is 1:1, and idk if it's worth while to support multiple this-accessing instance-assigned templates. Today, we could think of the classes template as being on the prototype, so it's shared between all instances. The property assigned template would not have that benefit. Instead, you can do this: import Component from '@glimmer/component';
export default class Hello extends Component {
value = "HELLO";
<template>
From top template: {{ this.value }}<br/>
<Subtemplate @value={{this.value}} /><br/>
</template>
}
const Subtemplate = <template>
From subtemplate: {{ @value }}
</template>; |
@NullVoxPopuli The context for this is trying to break up a complex template into one main and a few sub-templates within one component. I did end up passing around I understand that there may be a technical reason to have the 1:1 template/component relationship, however, from developer aesthetics perspective, I was surprised that Is it possible, if it makes sense, to define sub-templates on the prototype somehow, and to share the component? If property assignment is not the correct way to define it, maybe something like |
Naw it's more that In emberjs/rfcs#779, we have two definitions, around components (not
There is some wiggle room around the second, but (without having seen examples) it mostly gets in to understanding what
yeah, one thing that might not be intuitive with these components is that the otherwise, someone could define
it is not Is there any reason why defining components in module scope is not ideal for your use case? I know you said you were splitting up a large component -- but passing |
that said, there is some very early planned work to better align but I don't know if anyone is prioritizing it |
I'm going to close this, as any work in this space would need to be in babel-plugin-ember-template-compilation. I appreciate your use case, explanations, and we can keep discussing here if you want, but there is nothing for this library to do |
@NullVoxPopuli Thank you for the explanation. It sent me back to the docs that clearly state that
This is our current solution.
Recognizing sub-templates as separate components puts things in a new light. I'll keep on eye on emberjs/babel-plugin-ember-template-compilation#61. Thanks again. |
Having the following component:
I get the following output:
It seems intuitive that all templates defined within a
Component
would exposethis
to access the instance.The text was updated successfully, but these errors were encountered: