Ember Handlebars Templates in <head> tag

戏子无情 提交于 2019-12-20 10:55:11

问题


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:


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



来源:https://stackoverflow.com/questions/18445064/ember-handlebars-templates-in-head-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!