Skip to content

Instantly share code, notes, and snippets.

@lagartoflojo
Created July 26, 2013 16:17
Show Gist options
  • Save lagartoflojo/6090175 to your computer and use it in GitHub Desktop.
Save lagartoflojo/6090175 to your computer and use it in GitHub Desktop.
Ember.Handlebars.helper 'format', (body) ->
body = Handlebars.Utils.escapeExpression(body)
body = body.replace(/\n\r?/g, '<br>')
new Handlebars.SafeString(body)
# Usage: {{format stringWithNewLines}}
@etozzato
Copy link

thanks!

@bfcoder
Copy link

bfcoder commented May 1, 2015

May want to update your gist

Ember.Handlebars.helper 'format', (body) ->
  body = Ember.Handlebars.Utils.escapeExpression(body)
  body = body.replace(/\n\r?/g, '<br>')
  new Ember.Handlebars.SafeString(body)

# Usage: {{format stringWithNewLines}}

see http://guides.emberjs.com/v1.10.0/templates/writing-helpers/

With the new Ember using HTMLBars it needs to change. :]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment