chrisfarber / ember-breadcrumbs

An Ember.js component for adding breadcrumbs to your app.
MIT License
79 stars 34 forks source link

Does layoutName do anything? #5

Closed jrjohnson closed 9 years ago

jrjohnson commented 10 years ago

I wasn't able to make layoutName call a template, but maybe thats not what it does? Is it possible to specify a handlebars file instead of a compiled string?

chrisfarber commented 10 years ago

ember-breadcrumbs is a Component, so to understand this behavior I'm referring to the API docs: http://emberjs.com/api/classes/Ember.Component.html

It looks like the layout property takes precedence over the layoutName property. This means that if you want to provide a named layout, you need to set layout to null.

I can understand this is really not obvious, so I'm definitely open to thinking of other ways to support this.

jrjohnson commented 9 years ago

I tried all the paths I could think of to set layoutName and set layout to null and nothing worked. Or at least I couldn't get anything to fail in a way that let me move forward. I'm guessing it has something to do with this: https://github.com/emberjs/ember.js/issues/5499 I will try out the solution in that ticket and see if I can get it working and submit a PR.

pmdarrow commented 9 years ago

@jrjohnson did you end up getting this working?

pmdarrow commented 9 years ago

Here's how I ended up overriding the template:

BreadCrumbs.BreadCrumbsComponent.reopen({
  layout: Ember.computed(function() {
    return this.templateForName('components/mybreadcrumbs')
  })
});

I would suggest updating the docs to show something like this instead of what you currently have.

chrisfarber commented 9 years ago

I apologize for how much of a PITA it was to accomplish this. Thankfully a very nice solution has come along: ember-cli's addons. Ember-breadcrumbs v0.1.0+ fixes this issue.

DanChadwick commented 8 years ago

@pmdarrow -- thank you! This is a general solution for adjusting the layout (i.e. template) of a component without changing the component itself. I agree that this is worth mentioning.

pmdarrow commented 8 years ago

@DanChadwick you're welcome :smile: