Skip to content

Instantly share code, notes, and snippets.

@rinoldsimon
Last active May 24, 2016 03:02
Show Gist options
  • Save rinoldsimon/1d99363335aba1906ea8daba27db3239 to your computer and use it in GitHub Desktop.
Save rinoldsimon/1d99363335aba1906ea8daba27db3239 to your computer and use it in GitHub Desktop.
## 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