Long block of text in Jade textarea?

一曲冷凌霜 提交于 2019-12-06 18:54:18

问题


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?


回答1:


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



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/10659775/long-block-of-text-in-jade-textarea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!