LoginSignup
1
1

More than 3 years have passed since last update.

Node.js(Express) + Pug(Jade)でDBにtextareaから保存された改行を表示する

Last updated at Posted at 2020-01-25

コード

index.js
text.replace(/\r?\n/g, '<br>')
index.pug
 p !{text}

注意

#{text}で出力するのではなく、!{text}でないと表示されない。

備考

変数である textは、DBにtextareaから保存されたテキストのデータ

例えば、テキストエリアに、

ファッキンホット
ファッキンコールド

と入力した場合

上記の処理をしないと、
ファッキンホット ファッキンコールド

と表示される。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1