Last active
May 24, 2016 03:02
-
-
Save rinoldsimon/1d99363335aba1906ea8daba27db3239 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## nl2br Helper class for Ember > 2.0 | |
import Ember from 'ember'; | |
const { | |
Helper: { helper }, | |
String: { htmlSafe } | |
} = Ember; | |
export function nl2br([text]) { | |
var breakTag = '<br />'; | |
return new htmlSafe((text + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2')); | |
} | |
export default helper(nl2br); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment