Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8695

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

$
0
0

コード

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

注意

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

備考

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

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

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

と入力した場合

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

と表示される。


Viewing all articles
Browse latest Browse all 8695

Trending Articles