Last active
March 2, 2017 17:35
-
-
Save HyShai/1b6d7f1392e730b2db5e to your computer and use it in GitHub Desktop.
convert new lines to <br/> tags for rendering
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
//helpers/newline-br.js | |
import Ember from 'ember'; | |
export function newlineBr(text) { | |
var breakTag = '<br />'; | |
return new Ember.Handlebars.SafeString((text + '') | |
.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2')); | |
} | |
export default Ember.Handlebars.helper('newLineBr',newlineBr); | |
// Ember.Handlebars.registerBoundHelper('nl2br', function (text) { | |
// }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment