javascript - Rendering newline character in VueJS -
i'm creating note app users can add note entering multiline text in textarea. when save note in firebase being saved newline (\n) characters want visualize.
therefore, wrote filter replaces these characters <br />
, works great.
though, need render data using {{{note.content}}}
, user can inject html, css, , js executed.
should use dompurify validate content or there way safely render newline characters?
wrap content in pre
element.
a <pre>
element preserve whitespace within it, eg:
this followed newline, not can tell <br /> <br /> <pre>you can see newline after me! woohoo!</pre>
will result in:
this followed newline, not can tell can see newline after me! woohoo!
this way, not need filtering of newlines.
Comments
Post a Comment