javascript Jade textarea 中的长文本块?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10659775/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 10:36:35  来源:igfitidea点击:

Long block of text in Jade textarea?

javascriptnode.jstemplate-enginepug

提问by Connor

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

我在最新的 node.js 应用程序中使用了Jade。默认情况下,我希望在 textarea 中有很长的文本块。

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?

有任何想法吗?

回答by Pickels

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

回答by nomadic_squirrel

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:

| 对我很有用。不过,就我而言,我需要从 js 变量(通过渲染局部变量传递)获取值。这就是我最终的结果:

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

I hope that helps someone.

我希望这可以帮助某人。

回答by Noah Heldman

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 Textsection in the Jade docs for more information.

通读Jade 文档中的标签文本部分以获取更多信息。