
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
ember-cli-meta-data
Advanced tools
An Ember CLI add-on to easily set tags
(link, meta, script, noscript, etc.) in the document head.
Many social networks, sharing platforms, and search engines extract
data from <meta> tags within a page's head tag. With this add-on,
you can have those meta tags populated when entering individual Ember
routes. This allows you to keep all logic within your client side
application without needing a sophisticated web server to populate tags
correctly.
This add-on is perfect for combining with a prerendering server side solution such as prerender.io or with Ember Fastboot (Fastboot compatibility requires ember-cli-meta-data v2+ and Ember 2.7+ (currently beta)).
In your Ember CLI project directory run:
ember install ember-cli-meta-data
Version 4.0+ of this addon is designed to work with Fastboot >= 1.0.0-rc1. If you use an order version of fastboot stick with 3.X.
Version 2.0+ of this addon is built upon ember-cli-head and as a result is will work automatically out of the box with Ember Fastboot if you are running a version of ember >= 2.7.
If you are using another addon that makes use of ember-cli-head
(such as
ember-page-title), or
are directly using ember-cli-head in your app you will need to
create a custom app/templates/head.hbs file and include
ember-cli-meta-tag's component:
{{head-tags headTags=model.headTags}}
In order to dynamically add head tags from your routes all you need to
do is provide a headTags property on the route. This property can
either be an array of tags, or a function which when invoked with the
route's context returns an array of tags. The head tags service will
automatically collect all head tags from the currently active routes
after transition.
To define a head tag you will use the following structure:
{
// html element type (meta, link, etc.)
type: 'meta',
// unique id for nesting (see below)
tagId: 'meta-description-tag',
// key value attributes for the element
attrs: {
name: 'description',
content: model.get('description')
},
// optional element content
content: 'Element content here'
}
This library supports pulling tag definitions from nested routes
without creating duplicate tags. Deeper nested routes will override
parent route tags. In order to support this you need to provide a
unique tagId property on your tag definition. Only one tag with a
given tagId will ever be rendered in the head.
You can also define the tags by providing an object as the value for the meta property on the route. This can either be in-lined in your route definition, or set as a property on the route prior to the didTransition event.
// app/routes/some-page.js
import Ember from 'ember';
export default Ember.Route.extend({
headTags: [{
type: 'meta',
tagId: 'meta-og-name',
attrs: {
property: 'og:name',
content: 'Ice-T'
}
},
{
type: 'link',
tagId: 'canonical-link',
attrs: {
rel: 'canonical',
content: 'http://mydomain.org/'
}
}]
});
export default Ember.Route.extend({
afterModel: function(model) {
this.setHeadTags(model);
},
setHeadTags: function(model) {
let headTags = [{
type: 'meta',
tagId: 'meta-description-tag',
attrs: {
name: 'description',
content: model.get('description')
}
}];
this.set('headTags', headTags);
}
});
You can provide the headTags by implementing a headTags method on the route
that returns the appropriate head tags.
// app/routes/some-page.js
import Ember from 'ember';
export default Ember.Route.extend({
headTags: function() {
// here we are pulling meta data from the model for this route
let model = this.modelFor(this.routeName);
return [{
type: 'meta',
tagId: 'meta-description-tag',
attrs: {
name: 'description',
content: model.get('description')
}
}];
}
});
When you visit '/some-page' the document head tag will be updated as follows:
<head>
<!-- ... -->
<meta name='description' content='Ice-T'>
<!-- ... -->
</head>
These tags will automatically be cleared when transitioning away from this route.
If you want to update the head tags for a route outside of a full
transition (perhaps due to a controller query parameter change)
you can directly call collectHeadTags on the head-tags service and
all of the headTags in the current route hierarchy will be re-built.
// app/routes/some-page.js
import Ember from 'ember';
export default Ember.Route.extend(RouteMetaMixin, {
headTags: function() {
let controller = this.controllerFor(this.routeName);
// value of head tags updates with value of `era` on this
// route's controller
return [{
type: 'meta',
tagId: 'meta-title',
attrs: {
property: 'title',
content: controller.get('era')
}
}]
}
});
// app/controller/some-page.js
import Ember from 'ember';
export default Ember.Controller.extend({
headTagsService: Ember.inject.service('head-tags'),
queryParameters: {
era: 'e'
},
// this observer runs whenever the era query parameter updates
// which by default does not trigger a full route transition
// so we need to notify the service to rebuild tags
eraObserver: Ember.observer('era', function() {
this.get('headTagsService').collectHeadTags();
}),
});
Including the RouteMetaMixin in your routes is no longer necessary if you provide the headTags property. However it's use is still supported and documented here.
Instructions for developing on this add-on.
git clone this repositorynpm installbower installember serverember testember test --serverember buildFor more information on using ember-cli, visit http://www.ember-cli.com/.
FAQs
Ember meta data
The npm package ember-cli-meta-data receives a total of 3 weekly downloads. As such, ember-cli-meta-data popularity was classified as not popular.
We found that ember-cli-meta-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.