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

Andy Hu
Andy Hu
7,473 Points

Pug template multi line text content

https://teamtreehouse.com/library/using-pug-in-your-express-app at 03:12

The thing is, I went to barnyard ipsum site and generated some random text as the teacher says in the video, then I copied the whole paragraph and put it in the index.pug file after the "p" tag. But here's what I get from the browser:

Error: /Users/andy/Code/flashcards/views/index.pug:13:7 11| Augers oats hen cowpies. Ewes mushrooms zucchini in forage Harvester at sheep with tractor. Apples ducks straw, quail a ostriches donkey, hay hook cucumbers. Kidney beans ostrich trucks. Apples ducks straw, quail a ostriche. 12|

13| Donkey, hay hook cucumbers. Chainsaw foal hay hook, herbs at combine harvester, children is mallet. Haybine carrots soybeans, owls duck raising or, cheep in plows. Cauliflower a seeds quail. Feed in a woof, a farmers market. Post pounder calf, hay or duck is, tool shed horse. Apples ducks straw, quail a ostriches donkey, hay hook cucumbers. Veterinarian at Seeder eggs with watermelon ostriches. Mouse soybean. --------------^ 14| 15| Sweet corn hogs llamas or oink oink wind. Coo with rabbits ect. Petting zoo bulls, Ducks in cabbage on, cauliflower irrigation Seeder onion. Mallet herb. 16|

unexpected text ", hay"

It seems the paragram was pasted in multiple lines and it just won't work. How do I fix this?

  1. I know that in the video the whole paragragh was in a single line, but how did he do that is there a convenient way without manually deleting the newline characters?

  2. How do you put multiple lines as text content of an html element in pug?

Thank you

1 Answer

Max Klopsch
Max Klopsch
22,628 Points

You can find out how to enter multi-line text in a paragraph here: https://pugjs.org/language/plain-text.html#piped-text You need to add the pipe | character indented before each line.

When I try to get rid of formatting or new lines, I usually paste my text in the browser URL field and then copy it again from there.

You can of course also manually remove the new line characters. It also looks like you copied the line numbers and pipe characters from the website. Maybe you need to retry it and only select the text.