Using yield with components
Components can be set up in block or inline form. When in block form, components can yield information. In this recipe, we'll look at an example of using yield to show information in a template.
How to do it...
- In a new project, create a new student component:
$ ember g component student-info
This will create the student component.
- Edit the
student-info
template file and add some text:// app/templates/components/student-info.hbs This is information before the yield<br> {{yield}} This is information after the yield
The
{{yield}}
expression in the component will be where the text in the block will be rendered. - Add the new
student-info
component to the application template file:// app/templates/application.hbs <h2 id="title">Welcome ...
Get Ember.js Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.