-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Provide ability to inject html into test-body #154
Comments
@sangm Your goal is to move the global nav into the testing container, confirm? Assuming that I've successfully guessed your goal the workaround that comes to mind is Input:
Template usage: <foo>{{yield}}</foo> Output:
Would you be interested in writing a PR for this to Ember CLI? |
Of course! I'll start looking into it |
Note: that PR is likely going to need to be coupled with an RFC, but I'd like to see how invasive of a change it would be. I've already thought of a few weird things with my first idea: So this still needs design work. |
One concern is, @nathanhammond deprecated this lol https:/ember-cli/ember-cli/blob/fa03e267b0742aac51a9431b54c0476215c41bec/lib/broccoli/ember-app.js#L1712. Ignoring that for now... So, here's the general idea from a quick look:
First thing is to make changes to Signature for Once changes to Then we can do content = this.project.addons.reduce(function(content, addon) {
var addonContent = addon.contentFor ? addon.contentFor(type, config, content) : null;
if (addonContent) {
deprecate('The `' + type + '` hook used in ' + addon.name + ' is deprecated. The addon should generate a module and have consumers `require` it.', !~deprecatedHooks.indexOf(type));
// replace addonContent (will contain {{yield}}) with regex match
return content.concat(addonContent);
}
return content;
}, content);
/* matches {{content-for 'test-body'}} foo bar {{/content-for}} */
match: /\{\{content-for ['"](.+)["']\}\}([\s\S]+)\{\{\/content-for\}\}/g,
replacement: this.contentFor.bind(this) // within `contentFor`, we can pass in the matched args in [\s\S] |
@sangm I only deprecated these. ... they are too dangerous and encourage people to do bad things. Not all How do you propose to {{yield}} only into the (I'd forgotten that the hook inside of any addon has access to the currently-calculated |
I figured we add support for |
Yes, but what if |
I see... In Although I think the What do you suggest? |
Bump @nathanhammond |
I would like to raise the question of "how often do we feel this is needed?" I'm concerned that the use case of rendering content external to the application and then wiring it up to the application is an exceedingly rare use case. In which case I would argue that a one-off solution for the consumer is better than adding additional logic to this addon or Ember-CLI proper. |
This seems to have gone stale, and I believe a solution was found in user land, so I'm going to close for now. |
For some context:
Ember events are only attached to
rootElement
event_dispatcherWithin the testing environment,
rootElement
resolves to#ember-testing
. ember-test-helpersLet's assume I have an addon that I would like to have it tested, but it generates content through
content-for
.Obviously, I can't test the contents of
foo-want-this-tested
.Would love to work on this, but if there are already options on how to achieve this what is it, or can I get some guidance on implementation?
contentFor
seems very limitedThe text was updated successfully, but these errors were encountered: