Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
ember-wormhole
Advanced tools
This addon provides a component that allows for rendering a block to a DOM element somewhere else on the page. The component retains typical Ember context in terms of bound data and action handling. Ember Wormhole is compatible with Ember FastBoot as of version 0.4.0, so long as the destination element is part of Ember's own templates.
View a live demo here: http://yapplabs.github.io/ember-wormhole/
The source code for the demo is available here: https://github.com/yapplabs/ember-wormhole/tree/master/tests/dummy/app
This library is particularly useful for cases where you have UI that is the logical child of a component but needs to render as a top-level DOM element, such as a confirmation dialog.
This component tracks its element's child nodes. When inserted into the DOM, it appends its child nodes to a destination element elsewhere. When removed from the DOM, it removes its child nodes, so as not to orphan them on the other side of the wormhole.
Nothing else changes -- data binding and action bubbling still flow according to
the Ember component hierarchy. That includes usages of yield
, so blocks provided
to ember-wormhole
simply appear in another part of the DOM.
We thought you'd never ask...
Given the following DOM:
<body class="ember-application">
<!-- Destination must be in the same element as your ember app -->
<!-- otherwise events/bindings will not work -->
<div id="destination">
</div>
<div class="ember-view">
<!-- rest of your Ember app's DOM... -->
</div>
</body>
and a template like this:
{{#ember-wormhole to="destination"}}
Hello world!
{{/ember-wormhole}}
Then "Hello world!" would be rendered inside the destination
div.
If the ember-wormhole is destroyed its far-off children are destroyed too. For example, given:
{{#if isWormholeEnabled}}
{{#ember-wormhole to="destination"}}
Hello world!
{{/ember-wormhole}}
{{/if}}
If isWormholeEnabled
starts off true and becomes false, then the "Hello
world!" text will be removed from the destination
div.
Similarly, if you use ember-wormhole
in a route's template, it will
render its children in the destination element when the route is entered
and remove them when the route is exited.
Yes! Sometimes you feel like a wormhole. Sometimes you don't. Situations sometimes call for the same content to be rendered through the wormhole or in place.
In this example, renderInPlace
will override to
and cause the wormhole content to be rendered in place.
{{#ember-wormhole to="destination" renderInPlace=true}}
Hello world!
{{/ember-wormhole}}
This technique is useful for:
You can provide an element directly to the wormhole. For example:
{{#ember-wormhole destinationElement=someElement}}
Hello world!
{{/ember-wormhole}}
This usage may be appropriate when using wormhole with dynamic targets, such as rendering into all elements matching a selector.
This library is compatible with and tested against Ember 1.13 and higher.
With latest ember-wormhole and ember@2.10, you need to have a stable root element inside the wormhole block. This is something that the Ember Core team will continue to iterate and work on, but for now the work around is fairly straightforward.
Change:
{{#ember-wormhole to="worm"}}
{{#if foo}}
{{/if}}
<p>Other content, whatever</p>
{{/ember-wormhole}}
To:
{{#ember-wormhole to="worm"}}
<div>
{{#if foo}}
{{/if}}
<p>Other content, whatever</p>
</div>
{{/ember-wormhole}}
To add the ember-wormhole add-on to an existing project, enter this command from the root of your EmberJS project:
ember install ember-wormhole
If you'd like to set up a new EmberJS application with the ember-wormhole sample application configured, follow these steps:
git clone
this repositorynpm install
bower install
ember try:testall
ember test
ember test --server
ember server
For more information on using ember-cli, visit http://www.ember-cli.com/.
This addon was extracted from ember-modal-dialog. Contributions from @stefanpenner, @krisselden, @chrislopresto, @lukemelia, @raycohen and others. Yapp Labs is an Ember.js consultancy based in NYC.
0.5.2 (2017-06-12)
Merged pull requests:
FAQs
Render a child view somewhere else in the DOM.
The npm package ember-wormhole receives a total of 40,304 weekly downloads. As such, ember-wormhole popularity was classified as popular.
We found that ember-wormhole demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.