実際のモデル プロパティが設定されていない場合、ビューを特定の値にデフォルト設定したいことがよくあります。このプレースホルダーのテキスト/値は厳密には表示専用であるため、モデル imo に配置しないでください。
だから、これは私がやっていることです:
// Sample 'Model' for illustration purposes only.
var myModel = Ember.Object.extend({
  title: null,
  description: null,
  thumbUrl: null
});
/**
 * Sample View
 * Render view properties which are actually 
 * computed of the actual 'content' properties
 */
var myView = Ember.View.extend({
  template: Ember.Handlebars.compile('<p>Title: {{view.title}}</p> <p>Description: {{view.description}}</p> <p>Image: <img {{bindAttr src="view.thumbUrl"}}/></p>'),
  title: function () {
    return this.get('content.title') || 'Title goes here';// placeholder 'title' text
  }.property('content.title'),
  description: function () {
    return this.get('content.description') || 'This is your description'; // placeholder 'description'
  }.property('content.description'),
  thumbUrl: function () {
    return this.get('content.thumbUrl') || 'http://placehold.it/100x100';
  }.property('content.thumbUrl')
});
これらすべてのプロパティ、つまり「タイトル」、「説明」、「thumbUrl」のデフォルトを定義する際にボイラープレートを減らす方法についての提案はありますか?
Ember.computed.defaultToを調べましたが、使い方がわかりませんでした。これは私が実際にそれを想像する方法です:
var myView = Ember.View.extend({
  template: Ember.Handlebars.compile('<p>Title: {{view.title}}</p> <p>Description: {{view.description}}</p> <p>Image: <img {{bindAttr src="view.thumbUrl"}}/></p>'),
  title: Ember.computed.defaultTo('content.title', 'Title goes here'),
  description: Ember.computed.defaultTo('content.description', 'This is your description'),
  thumbUrl: Ember.computed.defaultTo('content.thumbUrl', 'http://placehold.it/100x100')
});
では、これはどのように行うことができますか?
この種のことを行うためのより良いアプローチがあれば、コメントで聞きたいです。
また、Ember.computed.defaultTo の機能へのポインタも非常に役立ちます。