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 Build a Simple Dynamic Site with Node.js Creating a Basic Template Engine in Node.js Binding Values

Gerry K
Gerry K
5,877 Points

Getting error: content is not defined

Here's a snapshot of my code http://w.trhou.se/m6xeqc93j1

When I go to run this and load up the web page I get the content is not defined error message, I assume that the program is trying to access the content variable outside the scope of the function that it is being set it. ( i.e. that was replaced in the for loop in mergeValues function in renderer.js).

Where did this variable come from in Andrew's code?

Thank you!

1 Answer

Steven Parker
Steven Parker
231,186 Points

The variable "content" should be a passed-in argument.

But in your definition of mergeValues, you wrote "contents" (with an "s") instead of "content".

Gerry K
Gerry K
5,877 Points

Thanks I have updated that but now when I add a username ( .../username ) I get another server issue saying: TypeError: content.replace is not a function

Steven Parker
Steven Parker
231,186 Points

That could be related to the encoding. Have you gone all the way to the end of the video where that is discussed?

J llama
J llama
12,631 Points

Steven you need to stop commenting on posts... you give worthless information time and time again and it is quite frustrating for new js users like myself (and apparently yourself)...

Steven Parker
Steven Parker
231,186 Points

I don't understand your comment, "J". I enjoy helping people (and don't find it frustrating). And this information was clearly of value to Gerry (2 years ago!). Perhaps you have a slightly different issue that this answer doesn't address.

If you do, try starting a fresh question where you can get a more specific answer for your own issue (and not necessarily from me).