Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Ember.js Routes and Templates Challenge: Basic Routes and Templates

Modify the Handlebars template in index.html so that the word "puppies" links to the puppies route.

I dont know what i need to do! :(

js/app.js
AnimalShelter = Ember.Application.create();
AnimalShelter.Router.map(function() {
    this.resource('kittens');
  this.resource('puppies');
});
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>

  <script type="text/x-handlebars">
    <p>We have so many cute <a href="{{#link-to 'puppies'}}">puppies</a>!</p>
  </script>

</body>
</html>

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Olavo;

Welcome to Treehouse!

The syntax for Handlebars links in Ember.js is

{{#link-to 'your route name'}}Some Text You Want As A Link{{/link-to}}

For the challenge you would want the link to be between HTML paragraph tags.

I hope that at least point you in the right direction.

Ken

Link to the challenge: http://teamtreehouse.com/library/emberjs/routes-and-templates/challenge-basic-routes-and-templates

Your answer didn't mention whether the 'a href' was need or not, but I managed to pass with:

<!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>

  <script type="text/x-handlebars">
    <p>{{#link-to 'puppies'}}puppies{{/link-to}}</p>
  </script>

</body>
</html>

Note: Some of the other ember.js forum threads also list an id for the script type="text/x-handlebars" line, like:

<script type="text/x-handlebars" id="puppies">

..but this is not necessary to pass this particular challenge.

Ricard Taujenis
Ricard Taujenis
4,383 Points

can someone please explain me why there should be two {{#link-to 'puppies' }} instead of {#link-to 'puppies' } im kinda puzzled by that idea