Skip to content
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

Passing context or metadata into component cards/atoms #82

Open
decasia opened this issue Apr 22, 2016 · 4 comments
Open

Passing context or metadata into component cards/atoms #82

decasia opened this issue Apr 22, 2016 · 4 comments

Comments

@decasia
Copy link

decasia commented Apr 22, 2016

I'd like to be able to pass some arbitrary metadata about a mobiledoc down into the Ember components that render cards and/or atoms. Is there any good way to do this at the moment?

Here's a use case: I have some metadata about a mobiledoc's author. I'd like to refer to this in building the payload for certain atoms.

At the moment, it seems to me that the only way to do this is to subclass the mobiledoc-editor component and write a custom template that passes in the additional properties here. That doesn't seem optimal to me, because there's no way to inherit a parent template and override only a subsection thereof. Among other things, it's hard for maintainability; every time the component template changed upstream, consumers would have to manually review changes to the code upstream and update...

I understand if you don't want unnecessary clutter in the code, but I think it would be quite helpful to provide some way for consumers to pass context into their atom/card components. Any suggestions? (I'd be happy to provide a PR if appropriate.)

@mixonic
Copy link
Contributor

mixonic commented Apr 22, 2016

@decasia I believe you want to pass cardOptions to the editor? They are then passed options to card invocations.

See: https://github.com/bustlelabs/mobiledoc-kit/blob/master/CARDS.md

@decasia
Copy link
Author

decasia commented Apr 22, 2016

ah, grand. Thanks!

@decasia decasia closed this as completed Apr 22, 2016
@decasia
Copy link
Author

decasia commented Apr 27, 2016

Hi @mixonic, I checked into this a bit more and it looks like there are a couple of changes that we'd need in ember-mobiledoc-editor in order to use the options hash in an Ember atom/card component. Basically, to get the end user's cardOptions passed into the ember card components, we'd need to do the following:

  • merge the consumer's options hash into the cardOptions callback hash that ember-mobiledoc-editor uses.
  • pass the options hash into the Ember component invocations.

I've tested this myself in this branch and it seems to work well. Would you be amenable to seeing this as a PR? I'd be happy to add unit tests.

@decasia decasia reopened this Apr 27, 2016
@mixonic
Copy link
Contributor

mixonic commented Apr 27, 2016

@decasia that change seems totally reasonable to me- would be great to have in a PR with some tests 😄 Please tag me on the PR to review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants