Learn
Watch the video to get an in-depth overview of the code used in the previous exercise. In case you want to watch it at a later time, here is the YouTube link.
The major steps of using Handlebars in a project:
- Add the Handlebars library to your project. — one option is to use a Content Delivery Network (CDN): MDN CDN documentation.
- Create a Handlebars script in your HTML file.
- In your JavaScript file, grab the HTML stored in the Handlebars script.
- Use
Handlebars.compile()
to return a templating function. - Pass in a
context
object to the templating function to get a compiled template. - Render the compiled template onto the web page.
Instructions
Move on to the next exercise when you’re ready!
Sign up to start coding
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.