What about Line Breaks in Jade?

前端 未结 10 1791
情书的邮戳
情书的邮戳 2020-12-08 03:46

I\'m pretty sure that this is a no-brainer but I didn\'t find any snippet of sample code. What\'s the best way to insert line breaks (aka the good ol\' br/)?

As far

10条回答
  •  -上瘾入骨i
    2020-12-08 04:19

    so that you're aware.. if you're pulling this information.. say from an SQL database where you've already manually entered in line breaks (say in a textarea of a form) you can do the following on the server to your output

    var contentParse = function(content){
        content = content.replace(/\n?\r\n/g, '
    ' ); return content; };

    and then in jade use

    !{content}
    

    the ! lets jade know that you're inserting raw html into the variable you're trying to render out

    source: https://github.com/visionmedia/jade#tag-text

提交回复
热议问题