{"id":13806524,"url":"https://github.com/yapplabs/ember-wormhole","last_synced_at":"2025-05-16T07:07:51.736Z","repository":{"id":29886940,"uuid":"33432378","full_name":"yapplabs/ember-wormhole","owner":"yapplabs","description":"Render a child view somewhere else in the DOM.","archived":false,"fork":false,"pushed_at":"2022-12-07T17:42:27.000Z","size":2563,"stargazers_count":284,"open_issues_count":35,"forks_count":62,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-08T17:17:57.485Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yapplabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-05T06:16:49.000Z","updated_at":"2024-05-15T11:22:05.000Z","dependencies_parsed_at":"2023-01-14T15:51:15.527Z","dependency_job_id":null,"html_url":"https://github.com/yapplabs/ember-wormhole","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yapplabs%2Fember-wormhole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yapplabs%2Fember-wormhole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yapplabs%2Fember-wormhole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yapplabs%2Fember-wormhole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yapplabs","download_url":"https://codeload.github.com/yapplabs/ember-wormhole/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485064,"owners_count":22078767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T01:01:12.876Z","updated_at":"2025-05-16T07:07:46.724Z","avatar_url":"https://github.com/yapplabs.png","language":"JavaScript","funding_links":[],"categories":["Packages","Ember CLI Addons"],"sub_categories":["End-user customization","UI Helpers"],"readme":"# Ember Wormhole [![Build Status](https://travis-ci.org/yapplabs/ember-wormhole.svg?branch=master)](https://travis-ci.org/yapplabs/ember-wormhole) [![Ember Observer Score](http://emberobserver.com/badges/ember-wormhole.svg)](http://emberobserver.com/addons/ember-wormhole)\n\nThis addon provides a component that allows for rendering a block\nto a DOM element somewhere else on the page. The component retains typical Ember\ncontext in terms of bound data and action handling. Ember Wormhole is\ncompatible with [Ember FastBoot](http://www.ember-fastboot.com/) as of version\n0.4.0, so long as the destination element is part of Ember's own templates.\n\n## Live Demo\n\nView a live demo here: [http://yapplabs.github.io/ember-wormhole/](http://yapplabs.github.io/ember-wormhole/)\n\nThe source code for the demo is available here: [https://github.com/yapplabs/ember-wormhole/tree/master/tests/dummy/app](https://github.com/yapplabs/ember-wormhole/tree/master/tests/dummy/app)\n\n## But Why?\n\nThis library is particularly useful for cases where you have UI that is the logical child of\na component but needs to render as a top-level DOM element, such as a confirmation dialog.\n\n## And How?\n\nThis component tracks its element's child nodes. When inserted into the DOM, it appends\nits child nodes to a destination element elsewhere. When removed from the DOM, it\nremoves its child nodes, so as not to orphan them on the other side of the wormhole.\n\nNothing else changes -- data binding  and action bubbling still flow according to\nthe Ember component hierarchy. That includes usages of `yield`, so blocks provided\nto `ember-wormhole` simply appear in another part of the DOM.\n\n## Show Me Some Code!\n\nWe thought you'd never ask...\n\nGiven the following DOM:\n\n```html\n\u003cbody class=\"ember-application\"\u003e\n  \u003c!-- Destination must be in the same element as your ember app --\u003e\n  \u003c!-- otherwise events/bindings will not work --\u003e\n  \u003cdiv id=\"destination\"\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"ember-view\"\u003e\n    \u003c!-- rest of your Ember app's DOM... --\u003e\n  \u003c/div\u003e\n\u003c/body\u003e\n```\n\nand a template like this:\n\n```hbs\n{{#ember-wormhole to=\"destination\"}}\n  Hello world!\n{{/ember-wormhole}}\n```\n\nThen \"Hello world!\" would be rendered inside the `destination` div.\n\nIf the ember-wormhole is destroyed its far-off children are destroyed too.\nFor example, given:\n\n```hbs\n{{#if isWormholeEnabled}}\n  {{#ember-wormhole to=\"destination\"}}\n    Hello world!\n  {{/ember-wormhole}}\n{{/if}}\n```\n\nIf `isWormholeEnabled` starts off true and becomes false, then the \"Hello\nworld!\" text will be removed from the `destination` div.\n\nSimilarly, if you use `ember-wormhole` in a route's template, it will\nrender its children in the destination element when the route is entered\nand remove them when the route is exited.\n\n## Can I Render In Place (i.e. Unwormhole)?\n\nYes! Sometimes you feel like a wormhole. Sometimes you don't. Situations\nsometimes call for the same content to be rendered through the wormhole or in place.\n\nIn this example, `renderInPlace` will override `to` and cause the wormhole content to be rendered in place.\n\n```hbs\n{{#ember-wormhole to=\"destination\" renderInPlace=true}}\n  Hello world!\n{{/ember-wormhole}}\n```\n\nThis technique is useful for:\n\n- Presenting typically-wormholed content within a styleguide\n- Toggling content back and forth through the wormhole\n- Parlor tricks\n\n## What if if my element has no id?\n\nYou can provide an element directly to the wormhole. For example:\n\n```hbs\n{{#ember-wormhole destinationElement=someElement}}\n  Hello world!\n{{/ember-wormhole}}\n```\n\nThis usage may be appropriate when using wormhole with dynamic targets,\nsuch as rendering into all elements matching a selector.\n\n## What Version of Ember is This Compatible With?\n\nThis library is compatible with and tested against Ember 1.13 and higher.\n\n### Important Note about using this library with Ember 2.10\n\nWith 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.\n\nChange:\n\n```hbs\n{{#ember-wormhole to=\"worm\"}}\n  {{#if foo}}\n\n  {{/if}}\n  \u003cp\u003eOther content, whatever\u003c/p\u003e\n{{/ember-wormhole}}\nTo:\n\n{{#ember-wormhole to=\"worm\"}}\n  \u003cdiv\u003e\n    {{#if foo}}\n\n    {{/if}}\n    \u003cp\u003eOther content, whatever\u003c/p\u003e\n  \u003c/div\u003e\n{{/ember-wormhole}}\n```\n\n## Ember's native in-element\n\nSince Ember 3.21 there is also a native `in-element` helper. This helper offer a bit less functionality than this addon,\nbut may be enough for your use case! For more info see\n[the in-element API docs](https://api.emberjs.com/ember/3.21/classes/Ember.Templates.helpers/methods/in-element?anchor=in-element)\nand [the excellent article by Faith Or comparing ember-wormhole and in-element](https://www.linkedin.com/pulse/emberjs-using-in-element-helper-faith-or/)\n\n## Development Setup\n\n### Simple Installation\nTo add the ember-wormhole add-on to an existing project, enter this command from the root of your EmberJS project:\n\n* `ember install ember-wormhole`\n\n### Setting Up The Demo\nIf you'd like to set up a new EmberJS application with the ember-wormhole sample application configured, follow these steps:\n\n* `git clone` this repository\n* `npm install`\n* `bower install`\n\n### Running Tests\n\n* `ember try:testall`\n* `ember test`\n* `ember test --server`\n\n### Running the dummy app\n\n* `ember server`\n* Visit your app at http://localhost:4200.\n\nFor more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).\n\n## Credits\n\nThis addon was extracted from [ember-modal-dialog](http://github.com/yapplabs/ember-modal-dialog).\nContributions from @stefanpenner, @krisselden, @chrislopresto, @lukemelia, @raycohen and\nothers. [Yapp Labs](http://yapplabs.com) is an Ember.js consultancy based in NYC.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyapplabs%2Fember-wormhole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyapplabs%2Fember-wormhole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyapplabs%2Fember-wormhole/lists"}