ember_tools.vim icon indicating copy to clipboard operation
ember_tools.vim copied to clipboard

Does this support pods?

Open eibrahim opened this issue 9 years ago • 8 comments

I tried gf on multiple things and it doesn't seem to be jumping anywhere. It always displays error:

can't find file 'xxxx' in path

eibrahim avatar Jun 07 '16 14:06 eibrahim

I haven't really tried to support pods, since I've never used a pod structure, but I'd like to give it a shot. Could you give me an example of your directory structure?

So, for instance, if you gf on a component in a template, where would that template be located? Right now, I assume templates live in app/templates/<path-to-template>.hbs, and component templates are either in app/components/<component-name>/template.hbs, or app/templates/components/<component-name>.hbs. Could you describe where these would be located in your pods?

AndrewRadev avatar Jun 08 '16 15:06 AndrewRadev

say you have a component called nav-bar, it will be located at

app/pods/nav-bar/component.js
app/pods/nav-bar/template.hbs

for a blog route it would be

app/pods/blog/controller.js
app/pods/blog/model.js
app/pods/blog/template.js
app/pods/blog/route.js

PS: Pod structure is so much better :)

eibrahim avatar Jun 08 '16 15:06 eibrahim

The Folder pods is optional or can be different per project. Not sure if this config has been removed. For example we don't use a pods folder but used the pod sturucture.

addon/
├── application
│   ├── adapter.js
│   ├── controller.js
│   ├── route.js
│   └── serializer.js
├── components
│   ├── application-container
│   │   ├── component.js
│   │   ├── style.scss
│   │   └── template.hbs
│   ├── creative-uploader
│   │   ├── component.js
│   │   ├── style.scss
│   │   └── template.hbs
│   ├── data-form
│   │   ├── component.js
│   │   ├── header <-- child component
│   │   ├── style.scss
│   │   └── template.hbs
│   ├── data-table
│   │   ├── cell <-- child component
│   │   ├── column <-- child component
│   │   ├── column-header <-- child component
│   │   ├── component.js
│   │   ├── editable-cells.js <-- mixin for compoment
│   │   ├── filterable.js <-- mixin for component
│   │   ├── header <-- child component
│   │   ├── selectable-columns.js <-- mixin
│   │   ├── selectable.js <-- mixin
│   │   ├── sortable.js <-- mixin
│   │   ├── style.scss
│   │   ├── template.hbs
│   ├── drop-down
│   │   ├── component.js
│   │   ├── container
│   │   ├── mixin.js
│   │   ├── template.hbs
│   │   └── toggle
│   ├── form-field
│   │   ├── component.js
│   │   └── template.hbs
│   ├── form-wizard
│   │   ├── component.js
│   │   ├── fieldset.js
│   │   └── template.hbs
│   ├── im-icon
│   │   └── component.js
│   ├── label-select
│   │   └── component.js
│   ├── login-form
│   │   ├── component.js
│   │   ├── style.scss
│   │   └── template.hbs

I just found this addon but I guess pod structure is just setting this up in the projectionist config. Haven't used it yet but will dig into it.

There is an open RFC for a new file structure https://github.com/dgeb/rfcs/blob/module-unification/text/0000-module-unification.md#example-application. Still in progress but it's pretty well defined.

https://github.com/fivetanley/ember-cli-migrator tries to solve the migration between classic, pod and new structures. Might be helpful for get an idea about the different structures.

mszoernyi avatar Jun 19 '16 22:06 mszoernyi

@eibrahim I've tried to add support for files within "app/pods". For components, for instance, it would be something like "if you gf on {{foo/bar-baz}}, check if app/pods/foo/bar-baz/template.hbs exists". Could you try out what has been described in the README and let me know which ones still don't work for your project structure? I don't have a real project to experiment with (that's structured like this), so I've been relying on specs.

AndrewRadev avatar Jun 28 '16 19:06 AndrewRadev

@mszoernyi For starters, I haven't even tried to support an "addons" directory. How does this work? Is it "app/addons", or is that in the root of the project?

What I currently do is look for an ember-cli-build.js file in the current or parent directories, and if I find it, I consider its containing directory the "ember root", which contains "app" and so on. Is this the case in your project? If there's no such file, can you think of a more reliable way to detect an ember application?

As for your example structure: Right now, a component like app/components/application-container/<component-contents> will be detected, so a gf on {{application-container}} will jump to app/components/application-container/template.hbs. In your case, it's not "app", but "addon", so maybe that's the only thing I need to change? Waiting for confirmation on where the "addon" directory is located in the project structure.

How does it work with child components? For instance, do you call {{data-table/cell}}, or do you write {{cell}} within the {{data-table}} templates and that one gets automatically namespaced? In the first case, it should actually work out of the box (after fixing the whole app/addons thing), but in the second case, I'll need to do some more adjustments.

Thanks for the links. Seems like a lot of content, though :). I'l see when I can go through it.

AndrewRadev avatar Jun 28 '16 19:06 AndrewRadev

Hi,

I have the same issue, I have this component :

{{kh-subscriptions-chart subscriptions=model.subscriptions}}

I want to go in app/pods/components/kh-subscriptions-chart/template.hbs but it doesn't find the file.

GCorbel avatar Nov 13 '16 12:11 GCorbel

@GCorbel In your case, it seems the component is in app/pods/components/kh-subscriptions-chart. Based on what @eibrahim explained, I thought it would be app/pods/kh-subscriptions-chart. Guess both work.

I've just pushed a change to support this.

AndrewRadev avatar Nov 13 '16 13:11 AndrewRadev

It works. Thanks a lot! You was very fast!

GCorbel avatar Nov 13 '16 13:11 GCorbel