Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Express Basics Using Templates with Express Express’s Response.render Method

Kevin Ohlsson
Kevin Ohlsson
4,547 Points

How does prompt variable in CARD.PUG know were the variable resides?

Hello

I dont understand Andrews (author) explaination of how the prompt variable in the pug template card.pug finds its variable.

https://expressjs.com/en/4x/api.html#res.render Documentation says: "The view argument is a string that is the file path of the view file to render."

app.get('/cards', (req, res) => { // creates url /CARDS
    res.render('card', {prompt: "what the"}); // what does CARD mean here? 
})

1 Answer

Kevin Ohlsson
Kevin Ohlsson
4,547 Points

i think i get it...

app.get('/cards', (req, res) => { // creates url /CARDS
    res.render('card', {prompt: "what the"}); // uses the pug file card and bridges app.js prompt with its call in the pug template
})