{"id":13806960,"url":"https://github.com/ef4/ember-root-url","last_synced_at":"2025-07-30T19:03:06.276Z","repository":{"id":31240379,"uuid":"127327029","full_name":"ef4/ember-root-url","owner":"ef4","description":"A template helper to keep your URLs relative to the app's rootURL.","archived":false,"fork":false,"pushed_at":"2022-01-25T20:45:00.000Z","size":338,"stargazers_count":10,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T10:17:23.255Z","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/ef4.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":"2018-03-29T17:46:49.000Z","updated_at":"2023-06-27T23:02:35.000Z","dependencies_parsed_at":"2022-08-07T16:15:37.521Z","dependency_job_id":null,"html_url":"https://github.com/ef4/ember-root-url","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ef4%2Fember-root-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ef4%2Fember-root-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ef4%2Fember-root-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ef4%2Fember-root-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ef4","download_url":"https://codeload.github.com/ef4/ember-root-url/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250458801,"owners_count":21433948,"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:18.657Z","updated_at":"2025-04-23T15:25:41.335Z","avatar_url":"https://github.com/ef4.png","language":"JavaScript","readme":"ember-root-url\n==============================================================================\n\nThis addon provides the `root-url` helper:\n\n```hbs\n\u003cimg src={{root-url \"images/hello.png\"}} /\u003e\n```\n\nIt's purpose is to make it easy to express a URL relative to your application's rootURL.\n\nExplanation\n------------------------------------------------------------------------------\n\nBecause Ember apps handle their own routing, they need to know their own rootURL. This is configured in your `config/environment.js`.\n\nIf your app includes some assets, those assets will also be available under the rootURL.\n\nIf you want a portable way to refer to those assets, you need to construct their URLs relative to rootURL. Otherwise the links can break if you deploy your app under a new rootURL.\n\n\n\n\n\nCompatibility\n------------------------------------------------------------------------------\n\n* Ember.js v3.12 or above\n* Ember CLI v3.12 or above\n* Node.js v12 or above\n\n\nInstallation\n------------------------------------------------------------------------------\n\n```\nember install ember-root-url\n```\n\n\nUsage\n------------------------------------------------------------------------------\n\nIf you have an image in your app's `public/images/hello.png`, you can link to it like:\n\n```hbs\n\u003cimg src={{root-url \"images/hello.png\"}} /\u003e\n```\n\nAssuming you are using the default `rootURL` of `/`, it will render like:\n\n```hbs\n\u003cimg src=\"/images/hello.png\" /\u003e\n```\n\nAnd if you have a customized rootURL of \"/my-app\", it will render like\n\n```hbs\n\u003cimg src=\"/my-app/images/hello.png\" /\u003e\n```\n\nOf course it's fine to pass any value, it doesn't need to be a literal:\n\n```hbs\n\u003cimg src={{root-url model.imageURL}} /\u003e\n```\n\nYou can also build root-relative URLs in JavaScript using `service:root-url`:\n\n```js\nexport default MyComponent extends Component {\n  rootUrl: service(),\n\n  @computed\n  get helloUrl() {\n    return this.rootUrl.build('images/hello.png')\n  }\n}\n```\n\n\nContributing\n------------------------------------------------------------------------------\n\nSee the [Contributing](CONTRIBUTING.md) guide for details.\n\n\nLicense\n------------------------------------------------------------------------------\n\nThis project is licensed under the [MIT License](LICENSE.md).\n","funding_links":[],"categories":["Packages"],"sub_categories":["Helpers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fef4%2Fember-root-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fef4%2Fember-root-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fef4%2Fember-root-url/lists"}