-
Notifications
You must be signed in to change notification settings - Fork 0
nl2br
Mike Byrne edited this page Mar 14, 2023
·
1 revision
Introduced 3.1.0
This function is similar to PHP's nl2br()
, inserts HTML line breaks (<br>
) before all newlines in a string
- nothing
- str - required - text string to insert HTML line breaks into
- replaceMode - optional - boolean - defaults to
true
- replace new line characters with<br>
, if set tofalse
,<br>
are inserted and new line characters are left in the string
- text string with HTML line breaks inserted
let text = `hello
world`;
text = nl2br(text); // 'hello<br><br>world'
With replaceMode
set to false:
let text = `hello
world`;
text = nl2br(text, false); // 'hello<br>\n<br>\nworld'