{{content-for'head'}} Ember-cli [英] {{content-for 'head'}} Ember-cli
问题描述
过去1个月我一直在使用Yeoman ember generator,现在我想给ember-cli一个尝试。我很抱歉,如果这个问题似乎非常新手,但我迫切需要一个解释。
我运行生成器并启动应用程序,一切正常。
ember new my-new-app
pre>
ember server
但我想知道如何
{content-for'head'}} app / index.html作品中的
查看 http://www.ember-cli.com/的其他示例#tutorials ,他们都没有使用这个特定的帮手?是因为他们使用旧版的ember-cli吗?为什么他们不使用这个内容 - 帮助?
我很确定ember.js没有这个内容 - 在默认情况下为助手,所以我猜猜ember-cli在哪里写了?它在哪里,它是什么?
此外,当我检查我的新应用页面的元素时,欢迎来到Ember.js的div标签出现在body标签,而不是head标签?怎么可能? {{mind-blow}}
(在app / index.html中,{{content-for'head'}}放在头标中)
非常感谢您的帮助。
解决方案最近添加到了ember -cli基于此讨论。
以下是提交中的相关代码:
EmberApp.prototype.contentFor = function(config,match,type){
var content = [];
if(type ==='head'){
content.push(calculateBaseTag(config));
content.push('< meta name ='+ config.modulePrefix +'/ config / environment'+
'content ='+ escape(JSON.stringify ))+'>');
}
content = this.project.addons.reduce(function(content,addon){
if(addon.contentFor){
return content.concat addon.contentFor(type,config));
}
返回内容;
},内容);
return content.join('\\\
');
};
I've been using Yeoman ember generator for the past 1 month and now, i'd like to give ember-cli a try. I'm sorry if this question seem extremely newbie, but i'm desperately need an explanation.
i run the generator and launch the app, everything works fine.
ember new my-new-app ember server
but i'd like to know how does
{{content-for 'head'}}
in app/index.html works?
When looking at other examples from http://www.ember-cli.com/#tutorials, none of them are using this particular helper? is it because they are using older version of ember-cli? Why weren't they using this content-for helper?
I'm pretty sure that ember.js doesn't have this content-for helper in default, so i'm guessing ember-cli wrote it somewhere? where is it and what is it for?
Also, when i inspect the element of my-new-app page, the div tag of 'Welcome to Ember.js' appeared at the body tag instead of head tag? How is that possible? {{mind-blown}}
( in app/index.html, {{content-for 'head'}} is placed inside head tag)
Thank you so much for your help.
解决方案It was recently added to ember-cli based on this discussion.
Here is the relevant code from the commit:
EmberApp.prototype.contentFor = function(config, match, type) { var content = []; if (type === 'head') { content.push(calculateBaseTag(config)); content.push('<meta name="' + config.modulePrefix + '/config/environment" ' + 'content="' + escape(JSON.stringify(config)) + '">'); } content = this.project.addons.reduce(function(content, addon) { if (addon.contentFor) { return content.concat(addon.contentFor(type, config)); } return content; }, content); return content.join('\n'); };
这篇关于{{content-for'head'}} Ember-cli的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!