Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Ember.js Routes and Templates Challenge: Application Template

no Idea where to start/

what do I do here?

index.html
<!DOCTYPE html>
<html>
<head>
  <title>Animal Shelter</title>
</head>
<body>
  <script src="js/libs/jquery-1.10.2.js"></script>
  <script src="js/libs/handlebars-v1.3.0.js"></script>
  <script src="js/libs/ember-1.8.1.js"></script>
  <script src="js/app.js"></script>

  <!-- THIS IS THE APPLICATION TEMPLATE. -->
  <script type="text/x-handlebars">

    <!-- MOVE THE DUPLICATE CODE HERE. -->

    <!-- RENDER THE NESTED RESOURCE HERE. -->

  </script>

  <script type="text/x-handlebars" id="kittens">
    <div class='container'>
      <nav class='navbar navbar-default' role='navigation'>
        <ul class='nav navbar-nav'>
          <li>{{#link-to 'kittens'}}Kittens{{/link-to}}</li>
          <li>{{#link-to 'puppies'}}Puppies{{/link-to}}</li>
        </ul>
      </nav>

      <h1>Kittens</h1>
      <p>Look at these kittens! They are so cute.</p>
    </div>
  </script>

  <script type="text/x-handlebars" id="puppies">
    <div class='container'>
      <nav class='navbar navbar-default' role='navigation'>
        <ul class='nav navbar-nav'>
          <li>{{#link-to 'kittens'}}Kittens{{/link-to}}</li>
          <li>{{#link-to 'puppies'}}Puppies{{/link-to}}</li>
        </ul>
      </nav>

      <h1>Puppies</h1>
      <p>These puppies will love you and snuggle you until your heart melts.</p>
    </div>
  </script>

</body>
</html>
js/app.js
AnimalShelter = Ember.Application.create();

AnimalShelter.Router.map(function() {
  this.resource('kittens');
  this.resource('puppies');
});

AnimalShelter.IndexRoute = Ember.Route.extend({
  renderTemplate: function() {
    this.render('kittens');
  }
});

1 Answer

Ken Howard
STAFF
Ken Howard
Treehouse Guest Teacher

Your kittens and puppies templates should each only have an h1 and p elements. You need to move the common (duplicate) code into the application template (the script tag that has the <!-- MOVE THE DUPLICATE CODE HERE. --> comment). You'll also need to "Ensure that the application template renders the nested resources."