Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics Using Templates with Express Expressโ€™s Response.render Method

Kevin Ohlsson
Kevin Ohlsson
4,559 Points

Why are variables defined in app.js?

Hello

In this tutorial Andrew (author) initalizes template variables in app.js and calls them in the pug template.

Is it normal to define template variables in app.js?

Wouldnt it be better to keep the content of the page seperate from the business logic that resides in app.js?

For example, create a file were all template variables are defined?

Does this make sense??

1 Answer

Mark Westerweel
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Mark Westerweel
Full Stack JavaScript Techdegree Graduate 22,378 Points

It is beyond the scope of the course at this point.

It is good thinking and yes, there are ways (of course).

I found a interesting post on stack you might find worth reading