Rendering the Component
In this lesson, you’ll learn how the components are rendered in an Ember application.
Output “ASCII stars”
We now have the necessary supporting code for rendering our star-rating widget. The next step is to lay out in the template what should be rendered. Just to see that it works, let’s output “ASCII stars” as a first step: "X"s for full stars, and "O"s for empty ones. The newly added lines of code are highlighted, and the removed lines of code are commented.
Press + to interact
{{!-- app/components/star-rating.hbs --}}{{!-- {{yield}} --}}{{#each this.stars as |star|}}{if star.full "X" "O"}}{{/each}}
The above use of if
is called in-line if. It’s the equivalent of the JavaScript ternary operator ?
. It takes an expression as its first ...
Access this course and 1400+ top-rated courses and projects.