-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Components with templates in pod structure #30
Comments
@rlivsey - With the current implementation, you would use the following:
I would agree that the following would be better for components:
I agree that that seems odd, and have been thinking of allowing an escape hatch (exactly the same as the current resolver does for I need to break up |
Gotcha, for now I'll keep with the template being in a sub-directory as at least then it's in the same part of the tree. |
@rjackson - Is It possible to put componet in nested directories? Like:
And specify this component in template like:
|
👍 for
Also This seems even better, maybe only two files doesn't call for a folder
|
+1 for /components/.../foo-bar/component.js
/components/.../foo-bar/template.hbs or /.../foo-bar/component.js
/.../foo-bar/template.hbs the above might have template of the component /nested/foo-bar clashing into the route /nested/foo-bar so maybe /components/nested/foo-bar/... seems to be a better option anything but /components/.../foo-bar.js
/components/.../foo-bar/template.hbs maybe i am having an OCD attack... I will just try not to think about it 🙈 |
I'm currently re-writing paths in my project so I can store them where I think they should live and have broccoli move them to where the resolver can find them. Massive hack, but works for now.
|
After the recent refactoring, I think we finally have a nice structure for handling this with minimal changes. var CustomResolver = Resolver.extend({
podBasedModuleName: function(parsedName){
var podPrefix = this.namespace.podModulePrefix || this.namespace.modulePrefix;
var fullNameWithoutType = parsedName.fullNameWithoutType;
if (parsedName.type === 'template') {
fullNameWithoutType = fullNameWithoutType.replace(/^components\//, '');
}
return podPrefix + '/' + fullNameWithoutType + '/' + parsedName.type;
}
}); PR incoming. |
Submitted #53 fixing. |
@rjackson thanks. how can it get this over in ember-cli? |
You can make a custom resolver that does this fairly easily (see code pasted above). Then use that See here for a sample Ember CLI app with this modification. |
@rjackson This is great, thank you for this refactor. Huge win. To make this slightly less invasive, I've renamed that method as-is and have added it, and some others, to the lookup patterns. moduleNameLookupPatterns: Ember.computed(function(){
return Ember.A([
this.mainTemplateBasedModuleName,
this.explicitTemplateBasedModuleName,
this.componentModuleName,
this.podBasedModuleName,
this.mainModuleName,
this.defaultModuleName
]);
}),
// https://github.com/stefanpenner/ember-jj-abrams-resolver/issues/30#issuecomment-46008394
componentModuleName: function(parsedName){
var podPrefix = this.namespace.podModulePrefix || this.namespace.modulePrefix;
var fullNameWithoutType = parsedName.fullNameWithoutType;
if (parsedName.type === 'template') {
fullNameWithoutType = fullNameWithoutType.replace(/^components\//, '');
}
return podPrefix + '/' + fullNameWithoutType + '/' + parsedName.type;
},
// Resolves: pods/posts/posts.hbs
mainTemplateBasedModuleName: function(parsedName){
var podPrefix = this.namespace.podModulePrefix || this.namespace.modulePrefix;
var fullNameWithoutType = parsedName.fullNameWithoutType;
if (parsedName.type === 'template') {
return podPrefix + '/' + fullNameWithoutType + '/' + fullNameWithoutType;
}
return null;
},
// Resolves: pods/posts/comments.hbs
explicitTemplateBasedModuleName: function(parsedName){
var podPrefix = this.namespace.podModulePrefix || this.namespace.modulePrefix;
var fullNameWithoutType = parsedName.fullNameWithoutType;
if (parsedName.type === 'template') {
return podPrefix + '/' + fullNameWithoutType;
}
return null;
}, |
I would be great to have a solution for this that doesn't involve a custom resolver. Are there any thoughts on this front? |
Unless I am mistaken this is already possible without modification. See #61 |
And #53 |
This is a naming question. If we have a component called big_combo, which has two files in it... |
This might be one for discourse, but wondering how to handle components with templates when in the pod structure (ie not storing them in the templates directory).
At the moment this works, but is a bit weird:
/components/foo-bar.js
/components/foo-bar/template.handlebars
But I'd like something like:
/components/foo-bar/component.js
/components/foo-bar/template.handlebars
or maybe:
/components/foo-bar/index.js
/components/foo-bar/template.handlebars
Is there a way to configure the resolver to handle that / or alternatives?
The text was updated successfully, but these errors were encountered: