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
[feature request] Allow for subdirectories in components #1219
Comments
Would you expect the components themselves to still be named |
The component names and usage can stay the same IMO. The resolver allows for replacing the file path |
You can generally allow for subdirectories in nearly all parts of the system (Routes, Controllers, Views, Templates, etc), but unfortunately due to a bug in Handlebars we cannot reference components (or helpers) in a template with a |
The Handlebars bug's fix: handlebars-lang/handlebars.js#797 (but that will only make it into 2.0 and since Ember does not support 2.0.0.alpha's yet we are stuck with no folders). |
I am surprised this is a handlebars issue? We can tweak the resolver, right? Because components must have at least one |
Again, I suggested modifying the resolver to handle this, but that was decided to be a bad idea (Note: I still think it is a good one). |
Judging from the contents of my own components folder:
I'd like to ask the core team to revisit the decision to allow for making subfolders in the |
I agree, and have submitted a PR: ember-cli/ember-resolver#56. |
This deviation from the pattern makes me nervous as now dashes or slashes are ambiguous and if we ever add slashes they will mean something different I would prefer to leave it how it is today |
@stefanpenner - I understand. Could we make it |
TL;DR having folders in the components directories would be nice for code-organization. This then does suffer from potential ambiguity or it suffers from inconsistency with the rest of the projects conventions. If it was the case, that we could use |
Can someone explain to me what the |
@wycats - |
We could also require a dash after the double-dash, so it would be:
Essentially, the goal is to be able to organize component files on disk (in subfolders) and working around the Handlebars bug. |
@wycats can you provide more input now that further clarification has been made? |
this is a handlbars bug, will be fixed in htmlbars and apparently @tomdale is working on a backport. Unfortunately we wont support this feature until then. |
It is fixed in Handlebars master (by @tomdale), but as far as I know will not be backported to Handlebars 1.x. I didn't realize he was working on backporting it further. |
Registering a custom
|
@ppcano - It would be easier to just implement an additional method to the resolver. |
Now that we're on HTMLBars, is this still an issue? |
Maybe I am late to the discussion, since components can be nested in subdirectories and I am already using them this way, but I am missing the reason for imposing the dash in a component's name. I thought that components would use their own names instead of classic tag names, and, for such, W3C recommends using a dash, like this: |
It actually boils down to us not believing So removing the |
Expect an updating pods RFC soon outlining this. |
This thread is everything about why I hate Ember. |
@jleppert I appreciate the constructive feedback... |
@stefanpenner HAHAHAHAHAHA... |
I wasted over an hour of time trying to figure out why ember wasn't finding my component, giving no clue as to why. Only to find out that it's some random decision instead of letting people decide how to name their files... |
@jleppert it is not random, it is to avoid ambiguity in the resolution of components and to prevent locking in functionality future work (local component lookup and some variants of angle bracket components) cannot support. Now it would be handy if in development we detected these scenarios and warned/threw a helpful error. Unfortunately, your original comment failed to provide any actionable feedback, which prevented me from realizing the actual pain and recommending this as a potential resolution. Although you may have frustrations, please be sure to provide it in the form of constructive feedback. Otherwise it is merely a wasted exchange. We respond quite well to polite constructive feedback, but aren't terribly motivated by excessively negative remarks (especially when they provide little or no concrete points). |
I agree with both of you. It seems like we have a painful error-case missing. @rwjblue any interest in adding an explicit error in this scenario? |
I disagree. If your goal is to provide for convention over configuration, you think it's wise to break with the convention of a standard directory structure and naming convention that has been in use as the standard of almost every OS and file system? People expect that when you name a file something it should be made available as that name and be resolved as such. If you're concerned about ambiguity, you can use a name space like you've already done. Imagine the frustration of creating a text file and naming it something only to find that the text editor not only won't open that file, it has no idea about the existence of said file because it doesn't conform to arbitrary naming conventions at the personal choice and whim of the text editor author? And not only that but it fails to tell the user the real problem, making an obvious problem more difficult and resulting in a discussion -- the file in fact was found, but we aren't considering it because it doesn't have the correct name. |
I'm happy to add debugging aids (assertions/warnings/deprecations/etc) if an actual scenario is provided. All we've gotten so far is that @jleppert is frustrated, no steps to reproduce or explanation of what was happening. @jleppert - Please open a new issue explaining the problems that you faced, and how we can reproduce them so that we might actually do something about this... |
@jleppert what exactly do you disagree with? |
The resolution without a dash is ambiguous in this domain, as an angle bracket component resolved via local component lookup wouldn't be differentiable from a real DOM tag. As with web components, the dash ensures no conflict with current or future platform provided tags, and is intended to unambiguously refer to a custom tag. This ultimately leads to two different mutually exclusive constraints, to resolve the tie we look to the domain where the entity is referenced html/htmlbars and consider the invariants (like DOM/web component naming conventions). It would be great if we could satisfy all constraints, but this scenario appears to require some trade offs. @wycats we do currently provide an error if the component was created via generators, but it would appear we need some sort of additional pre-flight check. This may fall into the category of ember Doctor like scripts, or maybe at resolution time in dev mode all tags trigger a check via resolver for an invalid component name, erroring or warning. You are likely more familiar then I with this part of glimmer, do we have such a hook? |
Glimmer2 provides a one-time hook for "tag name" -> "component name" that we could use. |
In my opinion, a lot of this pain can also be fixed by putting components in a pod structure. I used to have a huge Perhaps this option could be better advertised? I have been using Ember since pre 1.0 and didn't even know that this was an option until last week. |
Nice, that will be nice to hook into. Is this Glimmer or glimmer@2
There are some things that must be cleaned up before we swap over to pods being the default. It is likely still a good choice, but until that work happens I am uneasy to make it the default. Someone needs to "own" that transition, and help move it forward. |
@stefanpenner Does that mean folders in components are not going to be supported in the future? We currently use them for our components. |
there will be support for components in folders, but it will likely be via the local component lookup pattern i believe @rwjblue is working on as part of some next steps in making pods a default pattern. I am unsure if their is an RFC with that or not |
@sergetab Robert talked a bit about this in his talk at the Austin Ember Meetup, and again in the latest episode of EmberLand - maybe that would be of interest. |
I forget, but I believe there was a blocker @rwjblue faced in created an addon to test the "fractal pods" pattern. If so, has that cleared? And if so, want to spec it out a bit? I could take a stab at an addon implementing it to test with. |
👍 for "fractal pods" |
If we could use the {{component}} helper in block form we would at least have a work around for this.
|
@RustyToms how does that relate to this? |
Sorry, user error I think, it should work fine... |
It's unclear as it whether or not Ember supports component sub-directories. Some comments claim Ember supports it, while other comments do not. The official documentation does not say anything about sub-directories. I am coming from the AngularJS world and my simple Ember project has 23 components. It seems like an oversight that sub-directories are not supported. EDIT: StackOverflow answer - http://stackoverflow.com/questions/29038704/ember-components-in-subdirectory |
+1 would be a nice-to-have feature. |
@ibraheem4 @egee-irl you can create component in sub-directory. this will work as expected. While including you need to use |
I am developing a form editor, which currently consists of a multiple of components named like this:
It would be nice if components (and their templates) can live in their own subdirectory, like this:
To me it would be better for
The text was updated successfully, but these errors were encountered: