Skip to content

crelte / std/encdec / nl2br

Function: nl2br() ​

ts
function nl2br(str, isAttr?): string;

Convert newlines to
tags and escape HTML.

Warning ​

When used in an attribute, the isAttr parameter needs to be set to true.

Example ​

svelte
{@html nl2br("Hello\nWorld")}

Parameters ​

str ​

string

isAttr? ​

boolean = false

Returns ​

string