Embedding Applications and Feature Flags



You can embed an application into an existing page by changing the root element. When you create an application, by default the application template will be rendered by the application and attached to the body element. It is possible to include the application template to different element by using the rootElement property.

import Ember from 'ember';

export default Ember.Application.extend ({
   rootElement: '#app'
});

The URL can be disabled by setting the router's locationType flag to none. This property can be added in the config/environment.js file.

let ENV = {
   locationType: 'none'
};

The root URL can be specified in the Ember application, if it is served from the same domain. You also need to specify what the root URL of your Ember application is.

For instance, you can include the blogging application from http://emberjs.com/myblog/, and specify the root URL of myblog. This can be done by using the rootURL property router −

Ember.Router.extend ({
   rootURL: '/myblog/'
});

Feature Flags

The flagging details of feature flags will be specified in the features.json file. The code of feature flags can be enabled based on the project's configuration. The newly developed feature flag is available only in canary builds. It can be enabled by using the project's configuration file when the Ember.js community considers that it is ready for production use.

A feature can have any of the following three flags −

  • true − It specifies that the flag is present and enabled; the code must be enabled in the generated build.

  • null − It specifies that the flag is present, but disabled in the build output and can be enabled at runtime.

  • false − It specifies that the flag disabled and the code is not available in the generated build.

Developers include the entry of new feature in the FEATURES.md file along with the explanation of feature. They also add a new feature to the master branch on the github.

The feature can be enabled at run time by setting the link-to flag value to true before application boots. Open the config/environment.js file and set the flag as shown below −

let ENV = {
   EmberENV: {
      FEATURES: {
         'link-to': true
      }
   }
};
emberjs_configuring_emberjs.htm
Advertisements