Emberjs 模板编译在 RC1 中不起作用



我有

Esploreo.TE.Views.ItemView = Ember.View.extend({
    elementId : "item",
    templateName : 'itemTemplate'
});

以及类似的模板

<script type="text/x-handlebars" data-template-name="itemTemplate">
  content of templat
</script>

一切都很好。但我不想使用这种类型的编码。在以前的Ember版本中,可以在视图的定义中编写模板代码,如下所示:

Esploreo.TE.Views.ItemView = Ember.View.extend({
    elementId : "item",
    template: Em.Handlebars.compile('content of template'),
});

但它不起作用(emberjs1.0.0-RC.1)。这个版本中的这些功能被删除了吗?

这是一种使用Ember的奇特方式!不过,要回答您的问题,您需要在.create()的末尾添加.append(),如下所示:

App.ItemView.create().append();

强制性jsFiddle:http://jsfiddle.net/MGXDe/

虽然我不知道你的用例,但我再怎么强调也不为过,这似乎有点太奇怪了,近乎于Ember的糟糕用法。

最新更新