Recall & Review
beginner
What is a layout in Express template engines?
A layout is a main template that defines the common structure of your web pages, like header and footer, so you don't repeat the same code in every page.
Click to reveal answer
beginner
What are partials in Express templates?
Partials are small reusable template pieces, like a navigation bar or footer, that you can include in multiple pages to keep your code DRY (Don't Repeat Yourself).
Click to reveal answer
beginner
How do you include a partial in an EJS template?
You use the syntax
<%- include('partialName') %> to insert the partial template named 'partialName' into your current template.Click to reveal answer
beginner
Why use layouts and partials in Express apps?
They help keep your templates organized, avoid repeating code, and make it easier to update common parts like headers or footers in one place.
Click to reveal answer
intermediate
How does Express know which layout to use when rendering a page?
You can set a default layout in your template engine setup or specify a layout file when rendering a view, so Express wraps your page content inside that layout.
Click to reveal answer
What is the main purpose of a layout in Express templates?
✗ Incorrect
Layouts provide a shared structure like headers and footers for multiple pages.
Which syntax is used to include a partial in an EJS template?
✗ Incorrect
EJS uses <%- include('partialName') %> to insert partial templates.
Why are partials useful in template design?
✗ Incorrect
Partials help reuse common template pieces like navbars or footers.
How can you specify a layout when rendering a view in Express?
✗ Incorrect
You can specify the layout file by passing { layout: 'layoutName' } in res.render.
Which of these is NOT a benefit of using layouts and partials?
✗ Incorrect
Layouts and partials help with templates, not database queries.
Explain how layouts and partials work together in an Express app to build web pages.
Think about how a website header and footer appear on many pages.
You got /4 concepts.
Describe the steps to include a navigation bar partial in an EJS template using Express.
Focus on file creation and the include syntax.
You got /4 concepts.