Meteor: How to render line breaks?

后端 未结 5 557
滥情空心
滥情空心 2020-12-11 05:30

I have the following variable: \"hello↵↵world\". (the value is coming from a textarea)

The problem is when I ask Meteor to display it with {{content}}, everything ap

5条回答
  •  孤街浪徒
    2020-12-11 06:08

    One way is to create a handlebar helper:

    Handlebars.registerHelper 'breaklines', (text) ->
        text = text.replace /(\r\n|\n|\r)/gm, '
    ' return text

    and then to do so: (do not forget the three brackets!)

    {{{breaklines content}}}
    

提交回复
热议问题