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 (2015) Using Templates with Express The β€œresponse.render” Method

Why do I have to use a '|' character in the p element in order to render #{post.description}?

In the p:

p | #{post.description}

If I remove the '|' the text will not render. why?

matthewharrington2
matthewharrington2
Courses Plus Student 13,219 Points

I think that the single pipe is used when the content was moved down to the next line but should be processed as a single line.

Also, if you indent the pipe, it seems to add a 16px margin before and after the <p>.

I couldn't find any docs on it so this is what I found from some trial and error.

1 Answer

This is more a function of pugjs rather than Node or Express.

https://pugjs.org/language/plain-text.html

It looks like the pipe is NOT needed if all on one line. It is needed if on multiple. It appears that it is literally piping the functionality of the 'p' tag into the text. Without the pipe, it appears that it would be a child command.