0
0
Expressframework~5 mins

EJS template setup in Express - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Aapp.use('ejs')
Bapp.set('view engine', 'ejs')
Capp.engine('ejs')
Dapp.render('ejs')
Where should you put your EJS files by default?
Apublic folder
Bmodels folder
Cviews folder
Droutes folder
How do you send data to an EJS template from a route?
Ares.send(data)
Bres.json(data)
Cres.view('template', data)
Dres.render('template', data)
What file extension do EJS templates use?
A.ejs
B.html
C.js
D.json
Which of these is true about EJS?
AIt is a JavaScript templating engine
BIt is a CSS framework
CIt is a database
DIt is a server
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.