{"id":13805319,"url":"https://github.com/blimmer/ember-cli-server-variables","last_synced_at":"2025-03-16T17:37:00.912Z","repository":{"id":29511399,"uuid":"33049683","full_name":"blimmer/ember-cli-server-variables","owner":"blimmer","description":"Insert meta tag server variables into ember-cli built Ember applications","archived":false,"fork":false,"pushed_at":"2022-12-08T18:18:20.000Z","size":3121,"stargazers_count":31,"open_issues_count":18,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-21T11:03:13.112Z","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/blimmer.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-03-28T20:47:01.000Z","updated_at":"2023-04-21T16:42:28.000Z","dependencies_parsed_at":"2023-01-14T15:05:57.648Z","dependency_job_id":null,"html_url":"https://github.com/blimmer/ember-cli-server-variables","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blimmer%2Fember-cli-server-variables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blimmer%2Fember-cli-server-variables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blimmer%2Fember-cli-server-variables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blimmer%2Fember-cli-server-variables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blimmer","download_url":"https://codeload.github.com/blimmer/ember-cli-server-variables/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826788,"owners_count":20354220,"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:00:59.978Z","updated_at":"2025-03-16T17:37:00.906Z","avatar_url":"https://github.com/blimmer.png","language":"JavaScript","readme":"# ember-cli-server-variables [![Build Status](https://travis-ci.org/blimmer/ember-cli-server-variables.svg?branch=master)](https://travis-ci.org/blimmer/ember-cli-server-variables) [![Ember Observer Score](http://emberobserver.com/badges/ember-cli-server-variables.svg)](http://emberobserver.com/addons/ember-cli-server-variables) [![Code Climate](https://codeclimate.com/github/blimmer/ember-cli-server-variables/badges/gpa.svg)](https://codeclimate.com/github/blimmer/ember-cli-server-variables)\n\nAn [Ember CLI](http://www.ember-cli.com/) add-on to support adding variables\nto the generated index.html file's `head` tag.\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta name='your-app-token' content='example:app:token'\u003e\n    \u003cmeta name='your-app-user-location' content='Denver'\u003e\n    \u003cmeta name='your-app-json-data' content='{\"foo\":\"bar\"}'\u003e\n  \u003c/head\u003e\n\u003c/html\u003e\n```\n\nThis is handy when you need to dynamically insert variables from your application\nserver, such as a session application token to communicate with your API or a user's\nlocation based on their request IP address.\n\nYou can modify the blank `content` tags on your generated index.html file using\na library like [Cheerio](https://github.com/cheeriojs/cheerio).\n\n## Compatibility\n- Ember.js v4.12 or above\n- Ember CLI v4.12 or above\n- Node.js v18 or above\n\n## Usage\nYou need to install and configure this add-on for it to work properly.\n\n### Installation\n\n```\nember install ember-cli-server-variables\n```\n\n### Configuration\nAdd a `serverVariables` block your `environment.js` file.\n\nConfiguration Variables:\n\n  * vars (**required**): An array of your server variables. Convention is to use dasherized names.\n  * tagPrefix: a prefix to append to every meta tag to avoid collision. Defaults to `ENV.modulePrefix`.\n  * defaults: a POJO of default values for your server variables. **Note:** If\n  you don't provide defaults, the fallback is a blank string. Most of the time\n  you'll probably want to only provide defaults in development mode.\n\n```javascript\nmodule.exports = function(environment) {\n  var ENV = {\n    serverVariables: {\n      tagPrefix: 'your-app',\n      vars: ['app-token', 'user-location', 'key']\n    }\n  };\n\n  ...\n\n  if (environment === 'development') {\n    ENV.serverVariables.defaults = {\n      'app-token': 'dev-app-token',\n      'user-location': 'Denver'\n    };\n  }\n};\n```\n\n### Usage\nThis plugin provides a service to retrieve the server variables in your\nEmber app. You can use it like this:\n\n```javascript\nexport default Ember.Component.extend({\n  serverVariablesService: Ember.inject.service('serverVariables'),\n\n  userLocation: Ember.computed.reads('serverVariablesService.userLocation')\n});\n```\n\n## Troubleshooting\nSome tips \u0026 tricks if something isn't working correctly.\n\n### Check that the `{{content-for 'server-variables'}}` tag is present in your `app/index.html` file\n\nThis is how we insert the meta tags into your app. We try to do this automatically\nwhen you `ember install` this addon, but there are potentially times where this\noperation could fail. Your `app/index.html` file should look something like this:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"\u003e\n    \u003ctitle\u003eDummy\u003c/title\u003e\n    \u003cmeta name=\"description\" content=\"\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003e\n\n    {{content-for 'head'}}\n\n    \u003clink rel=\"stylesheet\" href=\"assets/vendor.css\"\u003e\n    \u003clink rel=\"stylesheet\" href=\"assets/dummy.css\"\u003e\n\n    \u003c!-- THIS IS THE IMPORTANT BIT! --\u003e\n    {{content-for 'server-variables'}}\n    \u003c!--------------------------------\u003e\n\n    {{content-for 'head-footer'}}\n  \u003c/head\u003e\n  \u003cbody\u003e\n    {{content-for 'body'}}\n\n    \u003cscript src=\"assets/vendor.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"assets/dummy.js\"\u003e\u003c/script\u003e\n\n    {{content-for 'body-footer'}}\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Ensure you've defined a `vars` array in your `config/environment.js` file\nMake sure that you followed the [configuration instructions](#configuration)\nto get your vars defined.\n\n## Contributing\nSee the [Contributing](CONTRIBUTING.md) guide for details.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE.md).\n","funding_links":[],"categories":["Packages"],"sub_categories":["CI/CD"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblimmer%2Fember-cli-server-variables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblimmer%2Fember-cli-server-variables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblimmer%2Fember-cli-server-variables/lists"}