-
-
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
Nested components with <AngleBrackets /> #428
Comments
As I read through this issue, it's not immediately clear to me specifically being requested. It seems like you are talking about yielded contextual components based on the first template snippet (which works perfectly fine with angle bracket invocation), but then you mention the desire to invoke components nested inside directories. More information about angle bracket invocation is being worked on by the learning team, but you can read more about them over in the RFC. Specifically, this section explains how dynamic invocations work (this would be things like a yielded contextual component e.g. |
@izelnakri perhaps it would be worth experimenting using ember-twiddle with the syntax Robert linked to and example above. I think we can close this issue as the RFC covers the case of angle bracket invocation using a variable. |
Sorry for the delay in my response. I'm requesting subcomponent lookups( I dislike using variables with let as it just adds extra lines and makes things harder to read, would be a very bad compromise in my opinion. This is what I'm suggesting: <!-- in src/ui/routes/x/template.hbs -->
<Modal.ConfirmationModal @text=model.userDeleteConfirmationText />
<Form @model=model.user as |form|>
<form.input attribute="username" /> <!-- This is currently supported but lack of subcomponent lookups make this very hard and hacky to implement internally when inputs have their own wrappers etc -->
</Form> Disallowing this lookup does not lead to better source code, so framework should not discourage components under component folders. My use of subcomponents are very minimal but when I use them they solve essential problems elegantly. I think the reason we dont have them right now is because it was simply not implemented as proof-of-concept. If the issue is something like having a global lookup context for templates, we can solve that problem separately, but I dont think this is related. Having Module-unification feature implicitly defining template contexts would make our build processes more custom thus worse, but I guess that isn't going to get implemented anyways either. |
You, my friend, have the smarts! and I support your request |
@izelnakri Ah I see, perhaps to continue the discussion of support for dot lookup with angle brackets a new RFC would have to be drafted.
@rwjblue where in the RFC was this ruled out? (I see that the dot syntax was not listed as how we use angle bracket invocation for components.) |
Per RFC 0311:(bottom of section)
(emphasis mine) AFAICT, These are the only two options available. However, there are some problems— Keep using curly-bracesWell this is just plain silly—Really?! Module UnificationPer the Module Unification I believe the following will apply:
Which to me means that if component A has a child component This method (which to me is the preferred) has two critical problems:
Conclusions
And in worse-case you could always flatten the component tree and dasherize your namespaces. P.S. Obviously contextual components are much better but they add on a lot of complexity and overhead manually managing |
Why? There is nothing wrong with curly bracket invocation, its definitely not going anywhere (seems very unlikely to be fully replaced ever). The main issue with this suggestion is that you loose out on all the other features of angle bracket invocation (yes, I agree its a great feature!)...
The Module Unification actually proposes two different mechanisms to address this (depending on the reason you are using subdirectories in the first place). The first is what we have collectively called "local lookup" (and is what you are talking about in the quoted text above). Local lookup style scoping is very useful when you have a specific component (or group of components) that are only used by a single parent component (and are effectively that components private collaborators). The second is by using packages. This mechanism is very useful when you are using subdirectories as a method of grouping things together (e.g. you have a
Well, this is always true until it isn't 😄. I do apologize that the module unification roll out has taken so long, but we have discovered many many things in the process and as such have had to course correct. Some of this has resulted in new RFCs (emberjs/rfcs#309 and emberjs/rfcs#367), and a bunch more thought. Also, it may or may not be obvious, but there are many irons in the fire at the moment that relate to the "Ember Octane" mental model (see here for what is "Ember Octane"):
As you can see, lots of these things have already shipped and we are continuing to push things... |
Back on topic here though, it is extremely unlikely that we would change course from the original angle bracket invocation RFC and allow slashes during invocation. Instead we need to continue pushing forward an arbitrary template import syntax that actually solves the reported issue ("can't use nested directories with angle bracket invocation") in a much better way. Given that this isn't a bug (the RFC specifically explains the position that was implemented), I'm going to move this issue to the RFCs repo (so that it can eventually be closed by the template imports RFC). |
I believe the end-game solution here is to make component imports explicit, so we don't need to conflate invocation syntax with module location information. |
See ef4#16 |
This landed in #457 |
Hi there,
I started using
<AngleBrackets />
for the first time this weekend and found some important issues I would like to raise.Previously I've been using nested components to group my
form
andmodal
window components. Example:For larger applications grouping
form
andmodal
related components under a folder make a lot of sense and encourages greater level of usability when it comes to functionality and naming.New syntax works for block-level forms:
However we also need to support nested level components, which is not supported currently. I think this is a major requirement for angle-brackets components in order it to be a true replacement for curly-braced components. I suggest the following syntax:
I can explain further why this is necessary if needed.
The text was updated successfully, but these errors were encountered: