Uh oh!
There was an error while loading. Please reload this page.
Template-only Components - #278
Conversation
Uh oh!
There was an error while loading. Please reload this page.
I have two questions about this, on two areas that might cause breakages not listed:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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 |
rtablada
commented
Dec 13, 2017
@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. |
rtablada
commented
Dec 13, 2017
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:
|
joukevandermaas
commented
Dec 14, 2017
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. |
cibernox
commented
Dec 14, 2017
@joukevandermaas you can. Add |
wycats
commented
Dec 14, 2017
@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. |
bartocc
commented
Dec 14, 2017
Great! I did not realize that adding This gives us a pretty good transition path I believe |
webark
commented
Dec 14, 2017
@bartocc things like ECC would adjust their architecture and ergonomics to account for this welcome change! |
mikkopaderes
commented
Dec 15, 2017
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 |
chancancode
commented
Dec 16, 2017
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? |
chancancode
commented
Dec 22, 2017
@webark correct, it has to be valid HTML content (which, by extension, includes "just text") |
chancancode
commented
Dec 22, 2017
@jamesarosen Correct. Since there are no instance in this case, I think your first suggestion is spot on. |
chancancode
commented
Jan 3, 2018
Thanks everyone for your participation! Since no major issues were found during the FCP, we will now close and merge this proposal. |
akatov
commented
Jan 18, 2018
The link in the description is wrong! Should be https://github.com/emberjs/rfcs/blob/master/text/0278-template-only-components.md |
wycats
commented
Jan 21, 2018
@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.
Rendered