Long block of text in Jade textarea?
Asked Answered
F

4

12

I'm using Jade in my latest node.js app. I'd like to have a long block of text in a textarea by default.

If I do something like this:

textarea(id="theTextarea")

it renders just fine:

<textarea id="theTextarea"></textarea>

However, if I do something like so:

textarea(id="theTextarea")
  Hello world.

I get this:

<textarea id="theTextarea">
  <hello>world</hello>
</textarea>

But I'd like it to be like so:

<textarea id="theTextarea">
  hello, world
</textarea>

Any ideas?

Footprint answered 18/5, 2012 at 21:8 Comment(1)
This is shown very clearly in the documentation.Burseraceous
E
23
textarea(id="theTextarea")
  | Hello 
  | world.
  | Hello
  | moon.
  | Hello
  | sun.
Excursion answered 18/5, 2012 at 22:45 Comment(0)
C
11

The | worked great for me. In my case though, I needed to get the value from a js variable (passed via render local variables). This is what I ended up with:

textarea#resp( name="resp", rows="6", cols="66" )
  | #{respStr}

I hope that helps someone.

Carbarn answered 3/9, 2014 at 19:34 Comment(0)
S
8

You can also do this, if you don't want a lot of pipes "clogging up" your markup (notice the dot character after the closing parens):

textarea(id="theTextarea").
  Hello
  world.
  Hello
  moon.
  Hello
  sun.

Read through the Tag Text section in the Jade docs for more information.

Segno answered 2/11, 2012 at 5:37 Comment(0)
C
0

I see this might be too late but hope it can help someone else, when working with textarea and want to output dynamic data, this worked for me

textarea.form-control#pdt_desc(name="pdt_desc", cols="10", rows="2")= product.pdt_desc

Reference: https://github.com/pugjs/pug/issues/2018

Casualty answered 2/8, 2020 at 10:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.