Recall & Review
beginner
What is EJS in the context of Express?
EJS (Embedded JavaScript) is a simple templating language that lets you generate HTML markup with plain JavaScript. It helps you create dynamic web pages by embedding JavaScript code inside HTML.
Click to reveal answer
beginner
How do you set EJS as the view engine in an Express app?
Use
app.set('view engine', 'ejs') in your Express app setup. This tells Express to use EJS to render views.Click to reveal answer
beginner
Where should EJS template files be placed by default in an Express project?
By default, EJS template files should be placed in a folder named
views at the root of your project. Express looks here to find the templates.Click to reveal answer
beginner
How do you render an EJS template from an Express route?
Use
res.render('templateName', data) inside your route handler. This renders the EJS file named templateName.ejs and passes data to it for dynamic content.Click to reveal answer
beginner
What is the purpose of passing an object as the second argument to
res.render()?The object contains data that the EJS template can use to display dynamic content. Each key in the object becomes a variable inside the template.
Click to reveal answer
Which line sets EJS as the template engine in Express?
✗ Incorrect
The correct way is to use app.set('view engine', 'ejs') to tell Express to use EJS for rendering views.
Where should you put your EJS files by default?
✗ Incorrect
Express looks for template files inside the views folder by default.
How do you send data to an EJS template from a route?
✗ Incorrect
Use res.render('template', data) to render the template and pass data for dynamic content.
What file extension do EJS templates use?
✗ Incorrect
EJS templates use the .ejs file extension.
Which of these is true about EJS?
✗ Incorrect
EJS is a templating engine that lets you embed JavaScript inside HTML.
Explain how to set up EJS in an Express app from scratch.
Think about the steps from installing to rendering a page.
You got /4 concepts.
Describe how data is passed from an Express route to an EJS template and how it is used.
Focus on the connection between route and template.
You got /3 concepts.