0
0
Expressframework~10 mins

EJS template setup in Express - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set EJS as the view engine in Express.

Express
app.set('view engine', '[1]');
Drag options to blanks, or click blank then click option'
Ahandlebars
Bpug
Cejs
Djade
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong template engine name like 'pug' or 'jade'.
Forgetting to set the view engine at all.
2fill in blank
medium

Complete the code to render the 'index' EJS template in an Express route.

Express
app.get('/', (req, res) => {
  res.[1]('index');
});
Drag options to blanks, or click blank then click option'
Asend
Bredirect
Cjson
Drender
Attempts:
3 left
💡 Hint
Common Mistakes
Using res.send instead of res.render.
Trying to render a template without setting the view engine.
3fill in blank
hard

Fix the error in setting the views folder path for EJS templates.

Express
app.set('views', path.[1](__dirname, 'templates'));
Drag options to blanks, or click blank then click option'
Adirname
Bjoin
Cresolve
Dbasename
Attempts:
3 left
💡 Hint
Common Mistakes
Using path.resolve incorrectly or confusing it with join.
Not importing the path module before using it.
4fill in blank
hard

Fill both blanks to set the views folder to 'views' and use EJS as the view engine.

Express
app.set('[1]', path.join(__dirname, 'views'));
app.set('[2]', 'ejs');
Drag options to blanks, or click blank then click option'
Aviews
Bview engine
Cviews engine
Dtemplate engine
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect setting names like 'views engine' or 'template engine'.
Swapping the two setting names.
5fill in blank
hard

Fill all three blanks to render 'profile' template passing a user object with name and age.

Express
app.get('/profile', (req, res) => {
  res.[1]('profile', { [2]: { name: 'Alice', [3]: 30 } });
});
Drag options to blanks, or click blank then click option'
Arender
Buser
Cage
Dsend
Attempts:
3 left
💡 Hint
Common Mistakes
Using res.send instead of res.render.
Passing data with wrong keys or missing properties.