5
votes

Is it possible for ember (specifically the application template) to operate inside the head tag in order to dynamically change things like the title tag, meta tags, external css stylesheets and the favicon?

If so, what would be a clean way of doing this?

1
Curious about this as well. In angular.js it's roughly as simple as <html ng-app>Donut
using this its simply easy, document.getElementsByTag("head").innerHTML += "<meta content = ''/>"; this can be achieved with raw JavaScript so why to rely on any library :)MarmiK
@MarmiK he asked for a "clean" way :Palbertjan
@MarmiK When the dom is loaded most of the meta tags are loaded and has no effect even if you change them after in javascript. So I guess he asked before loading the whole page. Since ember creates its index.html page and everything is then done in body how to increase your seo, etc, because they won't execute javascriptSahib Khan
Possible duplicate of Setting page title with ember.jsLiam

1 Answers

10
votes

In order to make this work, what I did was I created handlebar helpers. For Example, If you want to change the title for views which is very common, here is the helper.

Ember.Handlebars.helper('headTitle', function(title) {
  Ember.$('head').find('title').text(title);
}, 'title');

now in any view template you can just add the helper

{{headTitle 'View Header'}}

Here is the JSbin to check if its working