Created
December 4, 2014 21:41
-
-
Save ultimatemonty/9efec24377856fc3c91a to your computer and use it in GitHub Desktop.
Ember nl2br helper
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
Ember.Handlebars.registerBoundHelper('nl2br', function (text) { | |
var breakTag = '<br />'; | |
return new Handlebars.SafeString((text + '') | |
.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With sanitized user input and string interpolation (because)