O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Specifying view layouts

We already learned that a view's template is wrapped in an element, which is usually specified by the tagName property. In addition, this template can be wrapped by another template, as illustrated in the following figure:

Specifying view layouts

A template is marked as a layout by adding a yield expression, as shown in the following code:

<script type='text/x-handlebars' id='container'>
  <div id='container'>
   {{yield}}
  </div>
</script>

Just like the outlet expression, the yield expression serves as the portion that the template being wrapped will be inserted into. We then specify this layout in the view as:

var View = Ember.View.extend({ tagName: 'section', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required