-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Template-only Components #278
Conversation
I have two questions about this, on two areas that might cause breakages not listed:
|
Possibly a dumb question: EDIT: Just tested this on my app and it does indeed work. I guess this discussion is about making that be default behavior... |
I implemented the feature (behind a flag). You can try this on canary now: https://ember-twiddle.com/a2013417648c4dced26ae78e8aaa5e6a?openFiles=templates.application.hbs%2C Reminder: since the new semantics does not auto-reflect arguments as properties, you will have to use the named arguments syntax in #276 if you want to access them. (See |
@chancancode Looking at this PR I think there's some confusion in what are called "Template Only Components" Based on recent meetup and conference talks the idea of a Template Only component seems to be understood as a component that can be statically optimized and inlined where used or used as a single lookup without the overhead of a stateful component (similar to ember-ast-helpers or the current Glimmer implementation). While this RFC definitely removes the blocker of the surrounding div, I think that naming the removal of this div as "Template Only Components" will lead to confusion. |
As a suggestion I think "Template Only Component HTML". |
@rtablada it actually does pave the way for all of that. Here is the code to support Even if you are not familiar with the internals, you can probably intuit that the latter is doing a lot less work. More importantly, since it does not have an instance associated with it ( However, optimizability is not really a user visible change. From the user's perspective, this is mostly just a developer ergonomic improvement (which IMO stands on its own and then some). It just happens to also be a trojan horse for landing Glimmer Components and performance improvements as well. It's not how I would choose to teach it, but you are welcome to call this stateless component, pure component or functional component if you want 😉 |
I like the idea of "Outer HTML" very much, but at the moment, 2 things bother me with this RFC:
|
I agree with @bartocc; adding a javascript file shouldn't change what is being rendered. I very often start out with just a template and then add a javascript file later when I need a computed, for example. It would be very nice to have a way to preserve the 'outer html' behavior for components with a javascript file to support this 'upgrading' scenario. |
@joukevandermaas you can. Add |
@cibernox exactly! We already have the Glimmer components have a generally better story here for avoiding the need for a My general hope that we can move through these RFCs quickly enough so that the correct transition here will be from "template-only components" to "new-style JS file", and I think everyone is motivated to avoid letting the current status sit for long enough for these problems to become a very serious hassle. |
Great! I did not realize that adding This gives us a pretty good transition path I believe |
@bartocc things like ECC would adjust their architecture and ergonomics to account for this welcome change! |
This seems very similar to the functional component in React which I like. I welcome the change! I hate seeing my template without a root element and when it renders, it'll have |
This RFC was nominated and approved for Final Comment Period (FCP) yesterday, since most comments have already been replied to. The FCP with last for a week. If there are any substantial new arguments that are brought up during this time, the FCP will be restarted (or aborted). If you haven't reviewed the proposal yet, now would be a great time to do so. If I may, here is a summary of the main objections:
Meanwhile, since the feature have landed in canary behind a flag, I encourage you to give it a spin and get a feel for it, either using this Ember Twiddle or by using a canary build with the |
Will this break ember-feature-flags for template-only components? That addon injects If so, I have two ideas:
|
i assume one of these template files has to contain valid html.. It can’t be like a series of attributes and you could include on another tag, right? |
@webark correct, it has to be valid HTML content (which, by extension, includes "just text") |
@jamesarosen Correct. Since there are no instance in this case, I think your first suggestion is spot on. |
Thanks everyone for your participation! Since no major issues were found during the FCP, we will now close and merge this proposal. |
The link in the description is wrong! Should be https://github.com/emberjs/rfcs/blob/master/text/0278-template-only-components.md |
@akatov looks like it was fixed! Thanks! |
These features are enabled by turning them into a runtime flag. These flags are intended to be set by @emberjs/ember-optional-features. In the future, these runtime flags might be removed in favor of build-time flags once the infrastructure is in place.
These features are enabled by turning them into a runtime flag. These flags are intended to be set by @ember/optional-features. In the future, these runtime flags might be removed in favor of build-time flags once the infrastructure is in place.
[FEATURE ...] Enable emberjs/rfcs#278, emberjs/rfcs#280
Rendered