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 Express Basics (2015) Using Templates with Express Scaffolding Your Project’s Templates

Dante Harti
PLUS
Dante Harti
Courses Plus Student 2,813 Points

block content placement

I noticed that you placed the block content on the last line for the index.jade while for the post.jade, you place it under the extends keyword.

Is the placement of the block content important?

1 Answer

Yes, it tells the template rendering engine where the code should go.

In layout.jade, the block is at the bottom because it's after all the navigation, etc. If there was a footer after the block, you would see that there.

In index.jade and post.jade, because they extend layout.jade, they will get all the code from layout.jade and then insert anything nested within (underneath and indented) the block content, wherever that occurs in the extended template.

If you try and put anything outside of the blocks declared in the extended template, then you just won't see it, because it doesn't know where to put it.

Also, it doesn't matter if the extends statement is below all of the block code... it just makes more sense to declare it right at the top so you know where the rest of the code is coming from and what blocks to use.